- 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
Yes, that's correct. Creating the field on asmt_assessment_instance would make it available for all assessment instances. In my case I suggested it as a simple way to store the contract reference for the surveys created through the widget.
Using an M2M table between Contract and Assessment Instance is also a good approach, especially if you want to keep the assessment tables unchanged or maintain a cleaner data model.
Thanks for pointing that out.
Regards,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago
Are they publicly available (anonymous)? Because then you won't be able to find the trigger (it's anonymous for a reason).
Check the survey settings and also the trigger for the survey. If you can't make it in a way they need to login, maybe you can add it to the survey itself.
Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark
