I'm struggling to find the correct syntax for saving into a nested CDT from

Certified Lead Developer
I'm struggling to find the correct syntax for saving into a nested CDT from a SAIL dashboard. The snippet below creates a valid paragraph field from my nested CDT value but the saveInto causes an error when updating the form. I am using this style of notation because the elements are generated from an apply function so "IncidentVehicle" and "VehicleMake" are dynamic at runtime. The value will save when hard-coding local!dataArray["IncidentVehicle"].VehicleMake but this isn't an option for me as the .field cannot be parameterized.

a!paragraphField(
label: "CDT Data",
value: index(local!dataArray["IncidentVehicle"],"VehicleMake"),
saveInto: index(local!dataArray["IncidentVehicle"],"VehicleMake")
          )...

OriginalPostID-94523

OriginalPostID-94523

  Discussion posts and replies are publicly visible

  • Seems like you are executing an expression in saveInto.
    Try declaring a local variable (for e.g. load( local!paraField, ....)
    and in saveInto, try
    saveInto: local!paraField << Index(......

  • 0
    Certified Lead Developer
    Sorry Sathya but I don't see what you're pointing towards, there's a lot of ........'s
  • Typically, you would store the saveInto into a localVariable, ruleInput or acp. In your case, the saveInto seems to be simply executing the expression function.
    What I suggest you do is this.
    load(
    local!paraField:index(local!dataArray[ ... ] , "VehicleMake") ,
    a!paraField(
    label:"CDT",
    value:local!paraField,
    saveInto: local!paraField << index(local!dataArray["..."], "VehicleMake")

    Having said that, I am not sure why you are saving the same value into saveInto. Ideally, I'd assume you want to save the changes made to the paragraph field into a variable, right? In your case, this data never seems to be used anywhere.

    If your paraField is a readOnly, then you don't need to specify saveInto.

    If your paraField is something user enters and you need to look for that value from the dataArray, then your saveInto expression would change. Having said that, if that be the case, you shoudnt be using the paraField but a drop down that'd be your local!dataArray.

    I hope this is clear.
  • 0
    Certified Lead Developer
    Much clearer thanks :o) I can't define the local variable 1st because I don't know if it will exist, i.e. the whole form is dynamic and based on user roles/locations etc. The acp is populated from queryrecord and the results displayed on screen for the user to update.

    I guess my problem is that although I can use index style notation to get the value, I cannot use something like update array to set it back to the new typed value.
  • It need not be a local variable. It can be a rule input, for e.g
    If you're creating controls dynamically, I'd assume you'll have some sort of map to say which control and of what type to create for that dynamic page. You would use the same logic to create or pass variables to store the data into.
  • 0
    Certified Lead Developer
    Exactly, the value needs to be saved back into a specific element within a nested CDT. I am using the index functions to retrieve the value but I can't find a function or see how to write an expression to save it back to the same place. I have been able to cast the cdt into a label value array and do it that way I was hoping to not have to flatten out my CDT
  • You should be able to create a rule that does the update within the rule and returns the update array as output. Save this output into a local variable (you might not need to use this local variable anywhere and you can use this single variable all over the place so you don't have too many acp!.

    e.g.

    saveInto: loca!something << rule!updaetMyInputArray(array,index,_)
    where _ represents the value.

    Hope this helps.