Call the expression rule from the script task

I have two tables. The first "request" table has two fields: id (integer), name (text) and document (text).
The second table "documentation" also has two fields: iddocum (integer) and docum (text).
With a form that has a text field and a field to upload a file, fill both
fields and I give the send button. In my database "request" appears an id that is generated only for each shipment you make,
the name I have inserted and the document ([Document: 7917]). Also in the other "documentation" table that same one is saved
value of the document ([Document: 7917]).
Here comes my problem. I want the id generated only from the first table, I can pick it up and save it together with the
value of the document at a time.
For this last, I have an expression rule that does not work well.
index(
  index(
    a! queryEntity (
      entity: cons! CPRO_CT_DS_solicitudes,
      query: a! query (
        filter: a! queryFilter (
          field: "documentation",
          operator: "=",
          value: "[Document: 7945]"
        ),
        pagingInfo: a! pagingInfo (
                      startIndex: 1,
                      batchSize: -1,
                      sort: a! sortInfo (
                              field: "id",
                              ascending: false
                             )
                     )
      )
    ),
    "data",
    {}
  ),
  "id",
  null
)

I also have a process where I start the form and then with an XOR, I ask:
if I have not uploaded a document that finishes my process and if I have uploaded a document, in the script
task pick up the id. Do not do this part correctly.

  Discussion posts and replies are publicly visible

Parents
  • Hello Alastr, 

    Do you have the field doc of your CDT is integer? text? document?  if the nature of that field is Document I would suggest to use the Document as the type there.  if the docume is text that is by you are getting it as "[Document: 123123]"

    As explained If you need just to get the last record maybe just sort (using sortInfo object and pass it ascending:false())  and use a pagingInfo ( 1,1) 

    hope this helps

    Jose 

Reply
  • Hello Alastr, 

    Do you have the field doc of your CDT is integer? text? document?  if the nature of that field is Document I would suggest to use the Document as the type there.  if the docume is text that is by you are getting it as "[Document: 123123]"

    As explained If you need just to get the last record maybe just sort (using sortInfo object and pass it ascending:false())  and use a pagingInfo ( 1,1) 

    hope this helps

    Jose 

Children