
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi Experts,
I'm trying to sync the status for some requests to the related interaction:
Below is the script:
var $ = lib.c.$; var _ = lib.Underscore.require(); var _sf = system.functions; var p = print; //var relatedFile = $('request').newFile(); var r = $('request').select("status=\"Closed\" and current.phase=\"Closure\" and submit.date>=\'10/01/18 00:00:00\'").uniqueResult(); // p (r) var requestID = r.number; var rc; var relation = new SCFile("screlation"); if ( relation.doSelect( "source=\"" + requestID + "\" and " + "source.filename=\"request\" and " + "type=\"Related Interactions\" and "+ "depend.filename=\"incidents\" and "+ "depend.active = 0" ) == RC_SUCCESS ) p ("Request " + relation.source + " status is " + r.status ) var inc = $('incidents').select('incident.id="'+relation.depend+'"').uniqueResult(); p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open ) { inc['open'] = 'Open'; inc['current.phase'] = "Logging" inc['active'] = "false" inc.doUpdate(); p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open) }
********************* Getting the error***************************************************
Script 'A_Sync_Status' line 21: ERROR TypeError: inc has no properties at char 1
not sure why the error : inc has no properties at char 1 error is coming.
Please Suggest
Neo Jax
Accepted Solutions


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
As far as I can see You got no Interaction!
I made some changes (w/o any warranties)!
var $ = lib.c.$; var _ = lib.Underscore.require(); var _sf = system.functions; var p = print; //var relatedFile = $('request').newFile(); var r = $('request').select("status=\"Closed\" and current.phase=\"Closure\" and submit.date>='10/01/18 00:00:00'").uniqueResult(); if (r) { p(r) var requestID = r.number; var rc; var relation = new SCFile("screlation"); if ( relation.doSelect( "source=\"" + requestID + "\" and " + "source.filename=\"request\" and " + "type=\"Related Interactions\" and "+ "depend.filename=\"incidents\" and "+ "depend.active = true" ) == RC_SUCCESS ) { p ("Request " + relation.source + " status is " + r.status ); var inc = $('incidents').select('incident.id="'+relation.depend+'"').uniqueResult(); if (inc) { p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open ) inc['open'] = 'Open'; inc['current.phase'] = "Logging"; inc['active'] = false; rc = inc.doUpdate(); if (rc == RC_SUCCESS) { p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open) } else { p ("Error updating Interaction: " + RCtoString(rc)) } } } } p('finished!')
Some hints:
- no escape for the date quotes in query beginning and ending with "
- always check if you really get an object from uniqueResult()
- active-properties are Booleans ==> true/false without quotes (have a look at the dbdict)
- encapsulate the code block after the if condition with {}
- finally: I'm not sure about to manipulate the interaction this way..try to use RuleSets in Process Designer
Good Luck!
Bo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hello Neo Jax,
Thanks for your question.
If I undertstand your script correctly, seems like there is a problem with variable definitions in line 20, which is the root of the error you are seeing.
I suggest you to recheck the following definition to see if the line 21 is being built right.
var inc = $('incidents').select('incident.id="'+relation.depend+'"').uniqueResult();
Hope this helps!
BR!
If you find that this or any other post resolves your issue, please be sure to mark it as an accepted solution. If you are satisfied with anyone’s response please remember to give them a LIKE by clicking on the Thumb and show your appreciation.


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
As far as I can see You got no Interaction!
I made some changes (w/o any warranties)!
var $ = lib.c.$; var _ = lib.Underscore.require(); var _sf = system.functions; var p = print; //var relatedFile = $('request').newFile(); var r = $('request').select("status=\"Closed\" and current.phase=\"Closure\" and submit.date>='10/01/18 00:00:00'").uniqueResult(); if (r) { p(r) var requestID = r.number; var rc; var relation = new SCFile("screlation"); if ( relation.doSelect( "source=\"" + requestID + "\" and " + "source.filename=\"request\" and " + "type=\"Related Interactions\" and "+ "depend.filename=\"incidents\" and "+ "depend.active = true" ) == RC_SUCCESS ) { p ("Request " + relation.source + " status is " + r.status ); var inc = $('incidents').select('incident.id="'+relation.depend+'"').uniqueResult(); if (inc) { p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open ) inc['open'] = 'Open'; inc['current.phase'] = "Logging"; inc['active'] = false; rc = inc.doUpdate(); if (rc == RC_SUCCESS) { p ("Related Record for Request " + relation.source + " is " + inc.incident_id + " and its status is " + inc.open) } else { p ("Error updating Interaction: " + RCtoString(rc)) } } } } p('finished!')
Some hints:
- no escape for the date quotes in query beginning and ending with "
- always check if you really get an object from uniqueResult()
- active-properties are Booleans ==> true/false without quotes (have a look at the dbdict)
- encapsulate the code block after the if condition with {}
- finally: I'm not sure about to manipulate the interaction this way..try to use RuleSets in Process Designer
Good Luck!
Bo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
Hi bogart ,
Many thanks for the excellent reply. Hints were accurate & really a great learning for me.
Thanks a lot again for your response. it worked well, later i tweaked it few more conditions.
Regards
Neo Jax


- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
You're welcome!
Bo 🙂