Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Take Assessment from Form using UI Action

Muralikrishna2
Tera Contributor

Did anyone work on taking assessments from form of a custom table using UI Action ?

2 REPLIES 2

Peter Bodelier
Giga Sage

Now for a non AI generated answer, that actually might be helpfull.

 

You could take a look at how the OOTB risk assessment popup is generated on change requests. It is generated trough a macro there, but you might be able to adapt that in a UI Action as well.

 

/now/nav/ui/classic/params/target/sys_ui_macro.do%3Fsys_id%3D6b51c805c300101035ae3f52c1d3ae49


Help others to find a correct solution by marking the appropriate response as accepted solution and helpful.

Amit Gujarathi
Giga Sage
Giga Sage

HI @Muralikrishna2 ,
I trust you are doing great.

  1. Open the ServiceNow instance and navigate to the "sys_ui_action" table.
  2. Use a query to filter the records based on the criteria you need. In this case, you want to find UI actions related to taking assessments from a custom table. Assuming the custom table is named "AssessmentForm" and the UI action field storing the table name is "table_name", the query would be:

 

 

var tableName = 'AssessmentForm';
var uiActionRecords = new GlideRecord('sys_ui_action');
uiActionRecords.addQuery('name', 'CONTAINS', 'Assessment'); // Filter by UI action name if needed
uiActionRecords.addQuery('script', 'LIKE', 'gs\.getSession().get(' + tableName + ',.*'); // Filter by script content if needed
uiActionRecords.query();

 

  1. After executing the query, you

 

if (uiActionRecords.hasNext()) {
  // At least one UI action was found
  while (uiActionRecords.next()) {
    var actionName = uiActionRecords.getValue('name');
    var tableName = uiActionRecords.getValue('table_name');
    gs.info('UI Action "' + actionName + '" found for table "' + tableName + '".');
  }
} else {
  gs.info('No UI actions found for taking assessments from the custom table.');
}
​

can iterate over the results to determine if any records were found:

 

 

 


Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi