- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 11:19 AM
Hi everyone,
This is my first "big" scripting project, so please bear with me. I'd really appreciate your help.
I am trying to have the system automatically create a record in my new table called 'u_assignment_record' that includes who an incident was assigned to, who it is assigned to now, and who changed, every time someone updates the assigned to field on an incident. I have it mostly working...except for the part where the record that the script include creates is blank.
Now, I tried using the OOB Metric for Assigned To duration, but this does not give me what we need in the format we need it.
Here is what I have so far.
CLIENT SCRIPT:
I want to pass the system ID's for all the values (the 'sysparm_who' value was a desperate attempt to figure out what I'm doing wrong...still didn't work), so that I can run reports on related fields for the values. If I enable the commented out section in both the client script above and the script include below, I get an alert showing all the information I need (sys_id's for all values).
SCRIPT INCLUDE:
When I disable the alert parts above and change the value for an incident, I get a record in the u_assignment_record table BUT it's blank...
<xml>
<sys_created_on>2016-11-07 19:13:29</sys_created_on>
<sys_id>d885d1800f87a200e867ee68b1050e06</sys_id>
<sys_mod_count>0</sys_mod_count>
<sys_updated_by>stephanie.taveras</sys_updated_by>
<sys_updated_on>2016-11-07 19:13:29</sys_updated_on>
<u_assigned_by/>
<u_assigned_from/>
<u_assigned_to/>
<u_number/>
</u_assignment_record>
</xml>
As you can see from the XML above, all 4 parameters that I try to pass are blank on my table. I have tried setting these fields as Reference type, as String and as Translated Text. Same thing happens for each type. I did comment out the parameter and had it create a record with a static value (i.e '1', '2', '3', '4') and those values did pass into my table.
I would really appreciate anyone's help with this!
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 12:15 PM
OK.. I messed around a bit with the setup. You have to have the getXML() function, even if you do nothing with it:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 11:31 AM
I would bet that maybe the var inc = new GlideRecord(incident) line is throwing things off. It is not correct, not needed, and should be removed.
Try that and tell us what you get.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 11:48 AM
Also, is there a reason this is done Client Side? If you do this, every time a user switches the assignment group in the form, it will log to the table, regardless of whether that was submitted or not. So, if a user accidentally changes the assignment group, then changes it right back, that gets logged, though no change was actually done. I think the better candidate for this is a before update business rule with a condition of assignment group changes.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 12:02 PM
Hi Mike, that was actually my original train of thought, and I tried to do it that way. But for some reason I could not get the parameters I need to be sent from the business rule to the script include. Could you give me an example of what it would need to look like?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-07-2016 12:15 PM
