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
  • Hi Alastr, Are you looking to know how to perform save in the script task output?

    If yes, please see the screenshot all you need to do is save the data part of query entity results[Wrap it inside the expression rule] to the PV of same CDT type[Refer Screenshot ]. If you want to map it to the different CDT structure then you can do it by mapping query results individually to the fields of different CDT

    Let me know if anything is unclear.

  • with the rule that I have put I get a dictionary
    with(
    a!queryEntity(
    entity: cons!CPRO_CT_DS_docs,
    query: a!query(
    filter: a!queryFilter(
    field: "doc",
    operator: "=",
    value: ri!doc
    ),
    pagingInfo: a!pagingInfo(1,-1)
    )
    ).data

    Rule Input Name doc (Text) Expression "[Document: 7945]" Value "[Document: 7945]



    Now with the value "[Document: 7917]" from the table "docs" It is necessary to recover the
    "id" associated with that document And entered in the field "idSolic" of the other cdt.
    but this in a script task
  • 0
    A Score Level 1
    in reply to Alastr
    with(
    a!queryEntity(
    entity: cons!CPRO_CT_DS_docs,
    query: a!query(
    filter: a!queryFilter(
    field: "doc",
    operator: "=",
    value: tointeger(ri!doc)
    ),
    pagingInfo: a!pagingInfo(1,-1)
    )
    ).data

    Hi, Can you please use tointeger() function to get the id? [Use new code]

    Also when
    dictionary results mapped with CDT type it will do convrsion automatically.

    Hope this helps!

  • it gives me failure.

    In my table "docs" I have

    id doc
    10
    [Document: 7945]

    Now, with that id "10" that I have associated with that document,
    I want to enter it into the id of my other table that also has the doc field
     
Reply Children