Auto populate field based on field value from another reference field

ss123
Tera Contributor

Hi everyone!

 

I need this requirement where, when I select a value in "Service offering" field, I want to auto populate the "Service" field based the Parent field of the selected "Service offering" 

Example below:

If "Service offering" = Offering v1 , then, "Offering" = SAP Enterprise Services

 

 

SabrinaSalazar_1-1666170194912.png

 

 

Hope you can help me out 🙂 Thank you in advance everyone!

 

1 ACCEPTED SOLUTION

Saurav11
Kilo Patron
Kilo Patron

Hello,

 

Write a On change client script on service offering table:-

 

Saurav11_0-1666171996141.png

 

Use the below code:-

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
   if (isLoading || newValue === '') {
      return;
   }

  var caller = g_form.getReference('service_offering', setLocation);


function setLocation(caller) {
   if (caller)
       g_form.setValue('business_service', caller.parent);
}
   
}

 

Please mark my answer as correct based on Impact.

View solution in original post

7 REPLIES 7

hello,

 

For me it is working perfectly on my PDI.

 

When you say it is not working what is the behaviour you see?

ss123
Tera Contributor

Hi,

 

I modified the script and is now working. I removed the "If (caller)" under the function 😀

 

function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
var serv_offering = g_form.getReference('service_offering', setService);
}

function setService(serv_offering) {
g_form.setValue('business_service', serv_offering.parent); 

 

}
//Type appropriate comment here, and begin script below

Hello,

 

If my answer helped you can you also mark it as correct.

 

Thanks.