Whenever Catalog Form is submitted, it's variable data should get converted into JSON format and....
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
4 hours ago
Whenever a Catalog Form is submitted, it's variable data should get converted into JSON format and get attached to the RITM ticket.
How is it possible? Please help.
@Ankur Bawiskar @Dr Atul G- LNG @Viraj Hudlikar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Sorry mate, no idea on this.
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
No problem Sir. Thank you for your reply.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Hi @AbdurRahmanSnow ,
Yes, you can convert the submitted catalog variables into JSON and attach that JSON to the RITM. I’ve done something similar before in my instance; here’s how you can do it...
>> Create a Business Rule (or Flow) that runs after insert on sc_req_item (or your RITM table).
>> In the script, access current.variables to get all variable names & values.
>> Build a JSON object from those values, using .getDisplayValue() where needed for reference/choice fields. Serialize via JSON.stringify(...).
>> Use GlideSysAttachment to write that JSON string to a file (e.g.variables.json) and attach it to the RITM record.
If you found my response helpful, please mark it as ‘Accept as Solution’ and ‘Helpful’. This helps other community members find the right answer more easily and supports the community.
Kaushal Kumar Jha - ServiceNow Consultant - Lets connect on Linkedin: https://www.linkedin.com/in/kaushalkrjha/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
2 hours ago
Here's how I have done something similar with Flow Designer. First you need to create a custom action that looks like this:
for Content type, create choice values like you see in your sys_attachment table - text/plain, application/json;charset=UTF-8, image/jpeg... This custom action is generic enough to be re-usable any time you need to create an attachment.
The Script step also needs inputs created, mapped from the Action inputs, and the Script
(function execute(inputs, outputs) {
var attach = new GlideSysAttachment();
var rec = new GlideRecord(inputs.tableName);
rec.get(inputs.recordSysID);
var fileName = inputs.fileName;
var contentType = inputs.contentType;
var content = inputs.content;
var agr = attach.write(rec, fileName, contentType, content);
outputs.attachment = agr;
})(inputs, outputs);
and an output in the Script step
and finally an Action output mapped from the script step output
My Flow looks like this when calling the custom action
The Content script:
var variablesGR = new GlideRecord('sc_req_item');
variablesGR.get('sys_id', fd_data.trigger.request_item.sys_id);
return JSON.stringify(new GlideRecordToObject().toObject(variablesGR.variable_pool));