We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Widget

harry24
Tera Contributor

Hi , 

 

I have requirement where I have a field on catalog item says application when I select application respective questions should be populated, i have created custom table for storing question .

Now for displaying that I have created the custom widget and embedded that to my catalog item .

Now my issue is I dnt know how to capture the data of application that on change of application on client script of widget  

 

Can somebody help me .

 

Thanks 

8 REPLIES 8

@harry24 

you can do this approach

-> create a hidden multi-line text variable and always hide it on catalog and RITM form

-> when user submits questions in custom widget, your widget can set value in that hidden variable using below syntax. store in JSON format

{

"htmlquestion1name":"abel",

"htmlquestion2email":"abel.tuter@example.com",

"htmlquestion3phone":"80p"

}

Something like this in client controller to set

$scope.page.g_form.setValue('hiddenVariable', JSONSTRING);

-> then when RITM form opens, the widget can grab the variable value, parse it and again set it with whatever values user had submitted during catalog form submission

something like this in client controller to grab

$scope.page.g_form.getValue('hiddenVariable');

I believe I provided enough guidance on your poc and you can take it further from here based on your requirement and developer skills.

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

But how do I populate that questions in widget I am stuck with that like when user selects application then it should fetch data from custom table and then populate that in widget 

@harry24 

you can observe/watch within widget which observes if outside variable got changed or not

see below working solution

Widget that reacts to onChange event of Variable 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@harry24 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader