How to dot-walk a reference field in the record producer form?

Chaithra S
Tera Contributor

Hello Everyone,

 

I'm working on setting Incident Description and Short Description field values from the values entered by the user from a Record Producer form.

 

I have written below code to achieve, but still the producer values are not be seen in the Description and Short Description fields of an Incident form.

 

//If Service Offering is from XYZ Service Group

var serviceOffer = producer.service_offering;

if (serviceOffer.service_group == gs.getProperty('Service Group_XYZ')) {

    //current.description = "I am having trouble with my - " + producer.service_offering.getDisplayValue() + "\n" + 'Please describe your issue below - ' + producer.please_describe_your_issue_below_conditional;

    current.description = producer.please_describe_your_issue_below_conditional.getDisplayValue();

    current.short_description = "I am having trouble with my - " + producer.service_offering.getDisplayValue();

}

 

Could you please advise what could be error here?

 

Also, I'm not sure if I'm dot-walking the Service Group value from Service Offering reference field properly. 

 

Please provide your insights. Thanks in advance.

1 ACCEPTED SOLUTION

Since u_service_group looks like it is actually a List field, rather than Reference, you need to check if XYZ group is one of the service groups for the selected service offering.  Modifying your original script would look more like this with the corrected field name and indexOf method:

//If Service Offering is from XYZ Service Group
var serviceOffer = producer.service_offering;
if (serviceOffer.u_service_group.indexOf(gs.getProperty('Service Group_XYZ')) != -1) { //XYZ group found in service group field on service offering
    current.description = producer.please_describe_your_issue_below_conditional;
    current.short_description = "I am having trouble with my - " + producer.service_offering.getDisplayValue();
}

You don't need to use getDisplayValue() on text/string variables/fields.

 

View solution in original post

13 REPLIES 13

@Chaithra S  you can use indexOf in this case...

var serviceOffer = producer.service_offering

if (serviceOffer && serviceOffer.service_group) {

if (serviceOffer.service_group.indexOf(gs.getProperty('Service Group_XYZ'))>-1) {
current.description = producer.please_describe_your_issue_below_conditional;
current.short_description = "I am having trouble with my - " + serviceOffer.getDisplayValue();
}
}

Chaithra S
Tera Contributor

I made these changes Brad, still no luck. 

 

This is how Incident form looks. Seems like the description field value is being set by a Client script, but I don't find any relevant script.Capture 1.PNG

Check for Business Rules running on the incident table.  A before/after insert BR could be overwriting the field(s).

Chaithra S
Tera Contributor

The issue was due to below code existed in the Record Producer. It works if I comment below code. So, I added my code to the bottom of the Record Producer script, and it works fine now.

else {
    current.description = producer.description +
        '\n\nScope of Issue: ' + v_scope_text + '\nService State: ' + v_service_text;
}

Thank you Brad for your help, and it really helped me to know the format to dot-walk a List field type. 

 

Thanks everyone