Skip to main content
sivasuryap0002
Known Participant
October 17, 2022
Question

Datasubset

  • October 17, 2022
  • 4 replies
  • 7 views

HI ,
I am trying to update a process variable of type datasubset,
I am using the following code to update a particular index value,

a!update(
 data: pv!dataSubset,
 index: index(
   index(
     pv!dataSubset.data,
     wherecontains(
       1,
       tointeger(
         index(pv!dataSubset.data, "verse_no", {})
       )
     ),
     {}
   ),
   "sentOn",
   {}
 ),
 value: now()
) 

As the data is an array and at each index again is a CDT.
And I am trying to store it in the PV(type Datasubset) but I could not able to do it I am getting an error "(Expression evaluation error at function a!update: Invalid index: Cannot use multiple numeric indices into record for update) (Data Outputs)"

    4 replies

    harshitb6843
    Brainy
    October 17, 2022

    Your index function at line 3 must be returning multiple indexes. Anyway, the index function is not providing you a number or a property rather it will provide you the value of "sentOn" which is not the correct index that can be passed in a!update()

    sivasuryap0002
    Known Participant
    October 17, 2022

    Then How Can I pass the index of "SentOn" ?

    stefanhelzle0001
    Brainy
    October 17, 2022

    In this case, I recommend to use a foreach loop to iterate on the items. If the item matches your condition, update it, else, return the unmodified item.

    sivasuryap0002
    Known Participant
    October 17, 2022

    Thanks [mention:126a676c85024855948336691b0a7b92:e9ed411860ed4f2ba0265705b8793d05],
    Its working