Issues with a!PickerFieldUsers() function

Certified Associate Developer

Hello,

I have a requirement to build up a dynamic form based on the CDT we receive from API call. On the basis of keyAttribute value we are displaying the various controls. Now what i'm doing is I'm displaying the controls and their default values from the CDT received and saving the values to another CDT. Every other controls are working fine but with a!pickerFieldUser() funciton i'm getting errors. Below is the code I'm using

 

load(
local!tempUservalue:if(or(isnull(ri!defDataContentMetrics_cdt[ri!index].FormAttributeValue),
len(ri!defDataContentMetrics_cdt[ri!index].FormAttributeValue)=0),
null,
ri!defDataContentMetrics_cdt[ri!index].FormAttributeValue
),

with(
a!pickerFieldUsers(
label:ri!defDataContentMetrics_cdt[ri!index].ContentMetric,
lablePosition: "ABOVE",
maxSelections: 1,
value: local!tempUserValue,
saveInto: {
local!tempUserValue,
a!save(
ri!defDataContentMetrics_cdt[ri!index].FormAttributeValue,
if(
or(
isnull(save!value),
len(save!value) = 0
),
null,
save!value
)
),

 

a!save(
ri!ContentMetricsUpdatedValue_cdt[ri!index].FormAttributeValue,
if(
or(
isnull(save!value),
len(save!value) = 0
),
null,
save!value 
)
)
},
required: if(ri!defDataContentMetrics_cdt[ri!index].Required=1,true,false)
)

)
),

 

Where defDataContentMetrics_cdt is fetching values from API Call and ContentMetricsUpdatedValue_cdt is used to store the values. Can somebody tell me what is wrong inside the code?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • The username you are cancelling out is attempting to save into index position 10 of ri!ContentMetricsUpdatedValue_cdt. I am assuming you are generating this rule for each item in ri!defDataContentMetrics_cdt, but the CDT you are saving to does not have the same length, so your ri!index of 10 is not present for ri!ContentMetricsUpdatedValue_cdt.

    If you believe ri!ContentMetricsUpdatedValue_cdt does have the correct length, you should also check that ri!ContentMetricsUpdatedValue_cdt is marked as an array on your inputs.
  • 0
    Certified Associate Developer
    in reply to bradc
    Hey Brad,

    I got the issue actually it was the incorrect variable name causing the issue. Now its allowing me to save the values, But i'm still seeing random username as a default value, Even the expected default value is null. Any idea why that is happening?
  • I am not sure why that is happening there. Is it a user name that has been selected in another instance of this rule? Perhaps the indexes are confused mixed up somehow? Have you tried adding a textfield to this expression to debug the incoming value of local!tempUserValue?

    Also - you do not need the with() wrapped around the pickerField unless you intend to declare a local variable to be used in the pickerField. I doubt this is causing your issue, but it is not necessary.
  • 0
    Certified Associate Developer
    in reply to bradc
    Hey Brad,

    I checked this by placing a textfield control and its shows the value null(Which is the expected outcome), Also I tried by removing with() clause but it haven't make any difference. One more thing i noticed is its taking the same user name as a default value and when I checked the directory there is no such user with that username.
  • Hi - I have not encountered this behavior on my side and have not been able to recreate it. Did you search for the user that is appearing in the Inactive user list as well? Can you also try putting typename(typeof(local!tempUserValue)) in your textfield component to see what type is being returned by this local variable? Perhaps that will shed some light on the issue.
  • 0
    Certified Associate Developer
    in reply to bradc
    Hey Brad,

    I checked and found that the value stored in database column is not null, Its a value "NULL" that is why its taking default username who corresponds to "NULL"