- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2021 11:48 AM
Hello Community,
I need your help. Saving the backstory i need to do what i feel should be simple but for whatever reason i am unable to use my knowledge to be successful.
I have a working email script that is working, but i have (12) copies of this code in the script and i know i can reduce this down to one occurance in which it can interate through an array and only have one piece of code.
*****
if (current.variables.ldap != 'Yes') {
template.print("<br/><br/>" + current.variables.ldap.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.ldap.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.ldap_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.ldap_reason.getGlideObject().getQuestion().getValue())+"</b>";
} else {
template.print("<br/><br/>" + current.variables.ldap.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.ldap.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.ldap_reason.getGlideObject().getQuestion().getValue())+"</b>";
}
*****
What im trying to do is this...
var VARIABLE = ['ldap','fsso']; //<<<will be all 12 names in the list<<<
for( var i = 0; i < myArray.length; i ++){
var qna = myArray [i];
if (current.variables.[VARIABLE] != 'Yes') {
template.print("<br/><br/>" + current.variables.[VARIABLE].getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.[VARIABLE].getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.[VARIABLE]_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.[VARIABLE]_reason.getGlideObject().getQuestion().getValue())+"</b>";
} else {
template.print("<br/><br/>" + current.variables.[VARIABLE].getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.[VARIABLE].getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.[VARIABLE]_reason.getGlideObject().getQuestion().getValue())+"</b>";
}
break;
}
Anyone that can help me I would be greatly appreciative.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 10:17 AM
Spencer,
Sounds good; I think the issue is with resolving the dot walk and string combinations. I concatenated the string to hopefully solve this and attached a rough draft of the current script. First, we should ensure the variableName and variableVaule are correct before moving to this full script.
(function runMailScript(current, template, email, email_action, event) {
var list = 'ldap,fsso,data_at_rest,tls,endpoint,patch30,network,seperation,us_data,logging,risk_asmt,pentest';
var array = list.split(",");
for (var i = 0; i < array.length; i++) {
var VariableName = current.variables + "." + array[i];
gs.log('VariableName');
var VariableValue = VariableName.getValue();
gs.log('VariableValue')
if (VariableValue != 'Yes') {
template.print(VariableName + "." + getGlideObject().getQuestion().getLabel() + ": <b>" +
VariableName + "." + getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
VariableName + "_go_live." + getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
VariableName + "_reason." + getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("OR HERE<br/><br/>" + VariableName + "."+ getGlideObject().getQuestion().getLabel() + ": <b>" +
VariableName + "." + getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
VariableName + "_reason." + getGlideObject().getQuestion().getValue() + "</b>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 09:40 AM
sorry for delay.
the following are from the logs.
syslog.message=org.mozilla.javascript.EcmaError: "getGlideObject" is not defined.
Caused by error in sysevent_script_action.0b4812080a0a0b270f6dba560f256a9b.script at line 38
35: for (var i = 0; i < array.length; i++) {
36: var VariableName = current.variables + "." + array[i];
37: gs.log("sra mssa varname" + 'VariableName');
==> 38: var VariableValue = VariableName.getValue();
39: gs.log("sra mssa valueset" + 'VaribaleValue');
40: if (VariableValue != 'Yes') {
41: template.print(VariableName.getGlideObject().getQuestion().getLabel() + ": <b>" +
syslog.message=org.mozilla.javascript.EcmaError: "getGlideObject" is not defined.
Caused by error in Email Script: 'rp_mssa_email_loop' at line 41
38: var VariableValue = VariableName.getValue();
39: gs.log("sra mssa valueset" + 'VaribaleValue');
40: if (VariableValue != 'Yes') {
==> 41: template.print(VariableName.getGlideObject().getQuestion().getLabel() + ": <b>" +
42: VariableName.getGlideObject().getQuestion().getValue() +
43: "</b><br/> Implemented at go-live?: <b>" +
44: VariableName + "_go_live." + getGlideObject().getQuestion().getValue() +
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 10:11 AM
Spencer,
Run this script and provide the syslog record(s) output; the gs.log is stored in syslog table and can be accessed via typing syslog.list in the filter navigator.
(function runMailScript(current, template, email, email_action, event) {
var list = 'ldap,fsso,data_at_rest,tls,endpoint,patch30,network,seperation,us_data,logging,risk_asmt,pentest';
var array = list.split(",");
for (var i = 0; i < array.length; i++) {
var VariableName = current.variables + "." + array[i];
gs.log('VariableName');
var VariableValue = VariableName + "." + getDisplayValue();
gs.log('VariableValue')
}
})(current, template, email, email_action, event);
Thanks,
Derrick Johnson
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 10:13 AM
I need to get an application moved to production so give me a couple moments then I will be back on this.
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 10:17 AM
Spencer,
Sounds good; I think the issue is with resolving the dot walk and string combinations. I concatenated the string to hopefully solve this and attached a rough draft of the current script. First, we should ensure the variableName and variableVaule are correct before moving to this full script.
(function runMailScript(current, template, email, email_action, event) {
var list = 'ldap,fsso,data_at_rest,tls,endpoint,patch30,network,seperation,us_data,logging,risk_asmt,pentest';
var array = list.split(",");
for (var i = 0; i < array.length; i++) {
var VariableName = current.variables + "." + array[i];
gs.log('VariableName');
var VariableValue = VariableName.getValue();
gs.log('VariableValue')
if (VariableValue != 'Yes') {
template.print(VariableName + "." + getGlideObject().getQuestion().getLabel() + ": <b>" +
VariableName + "." + getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
VariableName + "_go_live." + getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
VariableName + "_reason." + getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("OR HERE<br/><br/>" + VariableName + "."+ getGlideObject().getQuestion().getLabel() + ": <b>" +
VariableName + "." + getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
VariableName + "_reason." + getGlideObject().getQuestion().getValue() + "</b>");
}
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-29-2021 10:24 AM
syslog.list is not available to me for some reason. I can get to logs but the shortcut you sent is not producing anything