- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
When a contract is signed, we want to send a survey to the customers who are part of the contract. This is done through custom widget which will allow agents to choose which user should receive the Survey. An email with the link to the Survey is sent.
Link: https://<<instance>>.service-now.com/business_portal?id=take_survey&type_id=cdde7524fb817e10706ff9464eefdc3e
On the contract I want to show all the users who have answered the survey and its value. How can I figure out which contract triggered the survey? I tried looking for trigger_id, trigger_table and task_id in the asmt_assessment_instance table. They are all empty when the customer answers the survey.
Note: An user can be associated with multiple contracts and can take survey for multiple contracts.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @vidhya_mouli ,
From what you described, the reason trigger_id, trigger_table, and task_id are empty in the asmt_assessment_instance table is because the survey is being opened directly using the take_survey URL. When surveys are sent from a custom widget, ServiceNow does not automatically link the survey to a record like a contract.
Since the survey is not triggered by a Survey Trigger Condition or a task record, those fields remain empty.
A simple way to solve this is to store the Contract reference when the survey is created.
Simple approach
Create a new field on the asmt_assessment_instance table.
Field name: u_contract
Type: Reference
Reference table: Contract
When your custom widget sends the survey to the selected users, pass the contract sys_id and save it in this field when creating the survey instance.
Then each survey response will have the contract stored on it.
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards,
Mohith A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Hi @vidhya_mouli ,
From what you described, the reason trigger_id, trigger_table, and task_id are empty in the asmt_assessment_instance table is because the survey is being opened directly using the take_survey URL. When surveys are sent from a custom widget, ServiceNow does not automatically link the survey to a record like a contract.
Since the survey is not triggered by a Survey Trigger Condition or a task record, those fields remain empty.
A simple way to solve this is to store the Contract reference when the survey is created.
Simple approach
Create a new field on the asmt_assessment_instance table.
Field name: u_contract
Type: Reference
Reference table: Contract
When your custom widget sends the survey to the selected users, pass the contract sys_id and save it in this field when creating the survey instance.
Then each survey response will have the contract stored on it.
Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards,
Mohith A
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Thank you. This was helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
And then the field will be there for each and every assessment instance that is created.
A m2m table would be better.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
I did this bit differently. I did not create a custom field. Instead updated trigger_id with the record sys_id and I was able to use this in other places.
