Update fields of another record with multiple conditions in a process

Hi! I have made a process in which my Invoice Lines (Record 1) are set with the status "Billed" in the end, after passing multiple logics.

Now, I would like to query the Purchase Order Lines (Record 2) from my process model and set their status to "Billed" too. In this case, I have to apply the following conditions:

1) The Purchase Order ID is the same as the used in my process 

2) The materials of the Order Lines are the same as the ones created in the process

I have been trying with the query database smart service (update-set-where) but it gives me problems when trying to filter by a more than one string (materials)

How can I afford this "update" in my process? Which smart services do you recommend me to use?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    For these scenarios, I create an expression rule which takes the invoice id as a rule input, then queries the items and modifies them in a foreach using a!update().

    Then I call that expression in a script task, storing the results in a PV. Then I write the items using a write records node.

  • Alright, I understand the idea, but I´m not sure how to take the invoice id as a rule input in my expression. Could I ask for an example with code in order to understand the structure? I have doubts to make the expression rule you mention, and how to add the a!foreach inside the a!queryRecordType

    The a!foreach structure should be something like this:

    a!forEach(
      items: ['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido'],
      expression: a!update(
        ['recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido'],
        "facturada",
        true
      )
    )

    And now this is the code I´m trying (it gives me an error and I dont know the idPedido as a rule input):

    a!forEach(
      items: 
      a!queryRecordType(
        recordType: 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido',
        fields: {
          'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{caf81eeb-f499-4adc-b078-f2692f6e38b2}ConcatPedidoMaterial', 'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido.fields.{fab0f2c1-705c-4acb-8d49-76f45778795f}facturada'
        },
        pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 100)
      ),
      expression: a!update(
        'recordType!{495578a9-1b23-4253-8145-6418faabe727}CPF Lineas Pedido',
        "facturada",
        true
      )
      ).data

    Any help would for the rest of the expression would be useful, thanks!

  • I have just put my code with the "insert code"; it was my fault, sorry!

Reply Children
No Data