Set value to business service depends service offering on incident form

Tal5
Giga Guru

Hi experts,
I have a challenge that I am facing.

My business service field is hidden.
I would like to populate it approximately after selecting a value in the service offering.
There is a child and parent relationship between them (business service is the parent of service offering).
There is no need for a client script because the business service field is hidden and therefore the placement reads in the registration of the form.

 

This is the script I wrote in the record producer, but the action doesn't actually happen after I press submit.
I would appreciate your assistance

 

var offeringGR = new GlideRecord("service_offering");

offeringGR.addQuerry('name',producer.service_offering);

offeringGR.Querry();

  if(offeringGR.next()){

    current.business_service = offeringGR.parent;

   }

 

 

 

1 ACCEPTED SOLUTION

Tal5
Giga Guru

Hi @Deepak Shaerma ,

thanks a lot for the help anyway, I was able to figure out what my problem was.
In the query, it was necessary to get the sys_id and not the name as I wrote because it is a reference field.
I will attach the corrected script here.

 

 

var offeringGR = new GlideRecord("service_offering");

offeringGR.addQuerry('sys_id',producer.service_offering);

offeringGR.Querry();

  if(offeringGR.next()){

    current.business_service = offeringGR.parent;

   }

 

View solution in original post

2 REPLIES 2

Deepak Shaerma
Kilo Sage

Hi @Tal5 

I found some typos error in your script and a little modification you need.

var offeringGR = new GlideRecord("service_offering");

// Correct method names: addQuery and query
offeringGR.addQuery('name', producer.service_offering);
offeringGR.query();

if (offeringGR.next()) {
    current.variables.business_service = offeringGR.parent.getDisplayValue();
}

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning ‌‌
Thanks & Regards 
Deepak Sharma


Tal5
Giga Guru

Hi @Deepak Shaerma ,

thanks a lot for the help anyway, I was able to figure out what my problem was.
In the query, it was necessary to get the sys_id and not the name as I wrote because it is a reference field.
I will attach the corrected script here.

 

 

var offeringGR = new GlideRecord("service_offering");

offeringGR.addQuerry('sys_id',producer.service_offering);

offeringGR.Querry();

  if(offeringGR.next()){

    current.business_service = offeringGR.parent;

   }