- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 12:42 PM
I have a gliderecord of an incident ticket that a business rule has in the advanced setting script.
I want to send a string version of all the contents that the glide object to my server.
Currently I have this code in the business rule and it does send the information to my server, just not in a legible way.
(function executeRule(current, previous /*null when async*/) {
var desc = current.toString();
... build api channel...
rm.setRequestBody(JSON.stringify({ "desc": desc});
...send JSON...
My server receives the JSON as: "desc": "[object GlideRecord]"
How can I send it as a string with all the contents of the record?
I have used functions such as current.getDisplayValue(); and this effectively gives the INC number.
But I want to just push all the ticket information to my server for parsing in python since I am much better with that language than Java.
I have also seen functions such as: GetAttribute(field name) but I don't know the field names that are present in the record.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-17-2017 12:57 PM
If you're after specific fields you can use current.getValue(fieldname) or current.getDisplaValue(fieldname) for fields like reference fields, choices, etc.
If you're after all the fields, you should be able to iterate through it like a normal Javascript object. (OK. Yes, Rhino converts it to Java, but hey JS concepts should still work)
I've never used it in a Business Rule, but have used a script like the following in Scripts - Background for troubleshooting:
var gr = new GlideRecord("incident");
if (gr.get("85071a1347c12200e0ef563dbb9a71c1")) {
for (var prop in gr) {
gs.print(prop + ":" + gr[prop]);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2022 02:33 AM
Hi Ishan,
Apologies. Your issue is buried in a reply and is easily missed.
If you haven't already resolved this issue, please do raise a question in the community detailing your use case and an experienced user can give you a tailored response.