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

Progress, anyway, but you're not making it past the if statement. Is the service_offering variable a reference? To the service_offering table? Is the u_service_group field on the service_offering table?  Is it a reference?  To the sys_user_group table?  What is the actual name of your system property?  What is it's value?

Chaithra S
Tera Contributor

 Hi Brad,

 

Service Group is a Reference field in the Service Offering form, and the system property value is the sys_id of the Service Group XYZ.

That answered some of the questions.  This is what the System Property needs to look like - with a different Value:

BradBowman_0-1727369110639.png

Name is space and case-sensitive.  Change your Record Producer script to this to see what messages you get when the RP is submitted

//If Service Offering is from XYZ Service Group
var serviceOffer = producer.service_offering;
gs.addInfoMessage('u_service_group = ' + serviceOffer.u_service_group )
gs.addInfoMessage('property = ' + gs.getProperty('Service Group_XYZ'));
if (serviceOffer.service_group == gs.getProperty('Service Group_XYZ')) {
	gs.addInfoMessage('IF CONDITION SATISFIED')
} else {
	gs.addInfoMessage('In else block');
}

 

Chaithra S
Tera Contributor

Thank you so much Brad. The Service Group reference field has other two service groups apart from XYZ, and this is what I got after submitting an incident.

 

Can you please advise how to only call XYZ service group and assign it to the description field of the producer form?

 

Capture.PNG

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.