- 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 12:18 PM
for whatever reason - as soon as value is looked for it stops
>>>>>.ldap.....ldap
(function runMailScript(current, template, email, email_action, event) {
// LDAP
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>");
}
// FSSO
if (current.variables.fsso != 'Yes') {
template.print("<br/><br/>" + current.variables.fsso.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.fsso.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.fsso_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.fsso_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.fsso.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.fsso.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.fsso_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// DATA_AT_REST
if (current.variables.data_at_rest != 'Yes') {
template.print("<br/><br/>" + current.variables.data_at_rest.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.data_at_rest.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.data_at_rest_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.data_at_rest_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.data_at_rest.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.data_at_rest.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.data_at_rest_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// DATA_IN_MOTION (tls)
if (current.variables.tls != 'Yes') {
template.print("<br/><br/>" + current.variables.tls.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.tls.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.tls_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.tls_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.tls.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.tls.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.tls_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// ENDPOINT
if (current.variables.endpoint != 'Yes') {
template.print("<br/><br/>" + current.variables.endpoint.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.endpoint.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.endpoint_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.endpoint_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.endpoint.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.endpoint.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.endpoint_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// PATCH30
if (current.variables.patch30 != 'Yes') {
template.print("<br/><br/>" + current.variables.patch30.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.patch30.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.patch30_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.patch30_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.patch30.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.patch30.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.patch30_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// NETWORK
if (current.variables.network != 'Yes') {
template.print("<br/><br/>" + current.variables.network.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.network.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.network_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.network_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.network.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.network.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.network_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// SEPERATION
if (current.variables.seperation != 'Yes') {
template.print("<br/><br/>" + current.variables.seperation.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.seperation.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.seperation_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.seperation_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.seperation.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.seperation.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.seperation_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// US_DATA
if (current.variables.us_data != 'Yes') {
template.print("<br/><br/>" + current.variables.us_data.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.us_data.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.us_data_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.us_data_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.us_data.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.us_data.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.us_data_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// LOGGING
if (current.variables.logging != 'Yes') {
template.print("<br/><br/>" + current.variables.logging.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.logging.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.logging_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.logging_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.logging.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.logging.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.logging_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// RISK_ASMT
if (current.variables.risk_asmt != 'Yes') {
template.print("<br/><br/>" + current.variables.risk_asmt.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.risk_asmt.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.risk_asmt_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.risk_asmt_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.risk_asmt.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.risk_asmt.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.risk_asmt_reason.getGlideObject().getQuestion().getValue() + "</b>");
}
// PENTEST
if (current.variables.pentest != 'Yes') {
template.print("<br/><br/>" + current.variables.pentest.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.pentest.getGlideObject().getQuestion().getValue() +
"</b><br/> Implemented at go-live?: <b>" +
current.variables.pentest_go_live.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.pentest_reason.getGlideObject().getQuestion().getValue() + "</b>");
} else {
template.print("<br/><br/>" + current.variables.pentest.getGlideObject().getQuestion().getLabel() + ": <b>" +
current.variables.pentest.getGlideObject().getQuestion().getValue() +
"</b><br/> Additional details/Comments: <b>" +
current.variables.pentest_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 12:27 PM
Spencer,
For testing can you run this code and provide the output logs:
(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];
template.print("<br / >>>>>>" + VariableName + "....." + array[i]);
var VariableValue = VariableName + "." + getDisplayValue();
template.print("<br / >>>>>>" + VariableValue);
}
})(current, template, email, email_action, event);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 04:52 AM
RESULT in email
>>>>There should be something below here >>>>>
>>>>>.ldap.....ldap
CODE used
(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];
template.print("<br / >>>>>>" + VariableName + "....." + array[i]);
var VariableValue = VariableName + "." + getDisplayValue();
template.print("<br / >>>>>>" + VariableValue);
}
})(current, template, email, email_action, event);
I have a total of 13 usecases to test - as soon as complete i will grab the log from the final UC
thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-01-2021 11:24 AM
My leadership has pulled the plug on this but i know we were close so i will credit you with correct response though we need some tuning - i know it should work.
will try again in the future