Populate field values in catalog form in service portal by clicking UI Action button

Anjaneyulu1
Giga Contributor

Hii All,

I have a requirement.

1. Create a new Category 'Service Request'.
2. Create Service Catalog with name 'Service Request for Incidents' with variables - Requestor(Type - Reference), Category (Type - Choice; with same options as in Incident), Short Description(Type - String), Description(Type - String), Currency( Type - Currency).
3. Create UI Action 'Çreate SR' which should be visible only when category is 'Service Request'.
4. On click of this button , it should redirect to catalog created in point no.2 and variables(Caller in Requestor, Category , Currency, SHort Description) should be auto- populated in catalog page with values available in Incident form.

 

-->I have done 1,2&3 points.

-->im struck at 4th point.

-->please help me in the 4th point how to sort it out.

 

Thanks,

anjaneyulu.

1 ACCEPTED SOLUTION

Ok thanks - so the reason requester is not getting populated is the name of your variable is actually 'requester', so I updated line 5 of your onLoad 'Incident details' catalog client script accordingly and it is now working:

g_form.setValue('requester', caller);

URL: https://dev89219.service-now.com/sp?id=sc_cat_item&sys_id=75732e4b1b564110dc0f40c6cc4bcb67&sysparm_caller=6fadf5f21bca0110dc0f40c6cc4bcb6b&sysparm_category=Service%20Request&sysparm_shortDescription=wert

Screenshot:

find_real_file.png

I also went back and set all the choices you created for your Category variable to have Inactive = true since they are no longer needed due to Choice table/field configuration, and this resolved the duplicate Service Request choice issue as well.

If this answer is helpful please mark correct and helpful!

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

View solution in original post

24 REPLIES 24

Hii Shloke,

I don't Know why ui action is not performing any action & it is not redirecting portal.

@Anjaneyulu Nalamothu 

Please refer to my screenshot above. It will work as I have tested it before posting the reply here to make sure it works.

Please do not mix with other responses which you have got. Follow the instruction mentioned by me above and it will work out for you as it is a tested code.

Say if you want this for a particular category then just add the condition in UI Action as below:

current.category == 'Value you want to check'

Regards,

Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shloke,

My code is tested as well and it works too... we basically have provided the same solution. 

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

chrisperry
Giga Sage

Hey Anjaneyulu,

Could you please copy and paste the script from your UI action?

Regards,

Christopher Perry

If this answer is helpful please mark correct and helpful!

Regards,
Chris Perry

Hi Christopher Perry,

I have not written any script in ui action.

 

Thanks,

Anjaneyulu.