- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 01:12 PM
Hi Guys, I have a query where I have two system properties for the Company Name. But the following code is not working, it works only for one property but not considering other one. Expectation is to get response based on the property value. Please suggest. Thanks.
updateCompany: function(id, filename){
var cmpName;
var xName = gs.getProperty('cmp_name_source');
var yName = gs.getProperty('cmp_my_name_source');
if (cmpName == xName){
return(this.updateCompany1(id, cmpName, filename)); //script Include
} else {
cmpName == yName;
return(this.updateCompany1(id, cmpName, filename));
}
},
updateCompany1(id, cmpName, filename) {
var responseBody;
var status;
var sm;
sm = new sn_ws.RESTMessageV2("<REST_message_record>", "get");
sm.setStringParameter("name_directory", cmpName);
sm.setStringParameterNoEscape("filename", filename);
responseBody = sm.execute();
status = responseBody.getStatusCode();
return status;
},
type: 'NewName'
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 02:42 PM
Ok, so it sounds like you need to be passing the cmpName in from somewhere because currently you are just setting it to be null in the second line:
var cmpName;
So you should probably be passing in cmpName as a function parameter similar to how you're already doing for id and filename. Also, there is an issue with your function declaration for updateCompany1. See updated script below:
updateCompany: function(cmpName, id, filename) {
var xName = gs.getProperty('cmp_name_source');
var yName = gs.getProperty('cmp_my_name_source');
if (cmpName == xName) {
return (this.updateCompany1(id, cmpName, filename)); //script Include
} else {
cmpName = yName;
return (this.updateCompany1(id, cmpName, filename));
}
},
updateCompany1: function(id, cmpName, filename) {
var responseBody;
var status;
var sm;
sm = new sn_ws.RESTMessageV2("<REST_message_record>", "get");
sm.setStringParameter("name_directory", cmpName);
sm.setStringParameterNoEscape("filename", filename);
responseBody = sm.execute();
status = responseBody.getStatusCode();
return status;
},
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 01:57 PM
>>> To help others, please mark this as Correct or Helpful if this response has been of any use. <<<
Hi Praveen,
Looks like your 'cmpName' will be empty when you compare it with xName so will always follow the 'else' path.
updateCompany: function(id, filename){
var cmpName;
var xName = gs.getProperty('cmp_name_source');
var yName = gs.getProperty('cmp_my_name_source');
if (cmpName == xName){
return(this.updateCompany1(id, cmpName, filename)); //script Include
} else {
cmpName == yName;
return(this.updateCompany1(id, cmpName, filename));
}
},
>>> To help others, please mark this as Correct or Helpful if this response has been of any use. <<<

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 01:59 PM
Based on the code you provided, it makes sense that the xName logic would never be executed because you are declaring var cmpName; without assigning it any value, and then checking if that empty cmpName var has a matching value to your xName sys_property, which isn't going to be possible.
It seems like you are missing code to pass in some parameter value to set cmpName from the jump. Could you please explain a bit further the var cmpName logic?
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 02:35 PM
The expectation is to to utilize the function 'updateCompany1' , for which the imports needs to execute based on the cmpName (whether it equals the xName or yName). Please share the better approach to do this. Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2022 02:42 PM
Ok, so it sounds like you need to be passing the cmpName in from somewhere because currently you are just setting it to be null in the second line:
var cmpName;
So you should probably be passing in cmpName as a function parameter similar to how you're already doing for id and filename. Also, there is an issue with your function declaration for updateCompany1. See updated script below:
updateCompany: function(cmpName, id, filename) {
var xName = gs.getProperty('cmp_name_source');
var yName = gs.getProperty('cmp_my_name_source');
if (cmpName == xName) {
return (this.updateCompany1(id, cmpName, filename)); //script Include
} else {
cmpName = yName;
return (this.updateCompany1(id, cmpName, filename));
}
},
updateCompany1: function(id, cmpName, filename) {
var responseBody;
var status;
var sm;
sm = new sn_ws.RESTMessageV2("<REST_message_record>", "get");
sm.setStringParameter("name_directory", cmpName);
sm.setStringParameterNoEscape("filename", filename);
responseBody = sm.execute();
status = responseBody.getStatusCode();
return status;
},
If this answer is helpful please mark correct and helpful!
Regards,
Christopher Perry
Regards,
Chris Perry