- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 12:32 PM
Could anyone also may be suggest to add functionality :
Clicking the assessment that has been submitted prompts submitter with yes/no pop up question: 'You have already completed assessment. Would you like to edit your existing assessment?'
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2023 07:56 PM
Thank you Punit. I tried this script is not getting anything after 'if'. It is exact same script except the table name is asmt_assessment_instance. Any thing I am missing, Please give me suggestion. I appreciate any input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-04-2023 03:39 PM
Cindy,
Here is a sample script that you find useful .
function onClickAssessment() {
var assessmentGr = new GlideRecord('ranking_assessment');
assessmentGr.addQuery('story', current.sys_id); // Replace "story" with the field name of the story reference field on your assessment table
assessmentGr.addQuery('submitter', gs.getUserID());
assessmentGr.query();
if (assessmentGr.next()) {
var answer = confirm('You have already completed assessment. Would you like to edit your existing assessment?');
if (answer == true) {
gs.getSession().setAttribute('assessment_id', assessmentGr.sys_id);
action.setRedirectURL('/assessment.do?sys_id=' + assessmentGr.sys_id);
}
} else {
action.setRedirectURL('/assessment.do?sysparm_query=story=' + current.sys_id); // Replace "story" with the field name of the story reference field on your assessment table
}
}
This script assumes that you have a table named "ranking_assessment" with a reference field to the "story" table, and that the "submitter" field is used to track who submitted the assessment. You'll need to adjust the script to match the field names and table names in your specific implementation.
To use the script, create a UI action on the form for your "story" table, and set the "Client" field to "true". In the "Script" field, paste the above script. This will create a button on the story form that, when clicked, will check if the user has already submitted an assessment for the current story. If they have, it will display a confirmation dialog asking if they want to edit their existing assessment. If they choose "yes", it will redirect them to the existing assessment record. If they choose "no" or they haven't submitted an assessment yet, it will redirect them to the assessment form to create a new assessment.
I hope this helps! Let me know if you have any questions or need further assistance.
Please mark my answer as a solution/helpful in case it adds value and moves you a step closer to your desired ServiceNow solution goal.
Thanks,
Punit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2023 07:56 PM
Thank you Punit. I tried this script is not getting anything after 'if'. It is exact same script except the table name is asmt_assessment_instance. Any thing I am missing, Please give me suggestion. I appreciate any input