-2

I'm building a simple pre-response scriptlet in HP OO 9. myBody refers to an input variable "body". I want to change the content of the body input variable depending on whether or not it is empty. I'm getting a complaint on line 5 and 6. Line 5 states missing ; before statement and line 6 states syntax error. What is going on here? I don't see anything unusual here.

myBody = body;
if (!myBody || myBody.length === 0) {
    body = "There are currently no unassigned servers to report.";
} else {
    body = ${myReport};
}
JLRishe
  • 99,490
  • 19
  • 131
  • 169
Martin Erlic
  • 5,467
  • 22
  • 81
  • 153
  • What is `${myReport}`? And what is "HP OO 9"? – Pointy Jul 12 '16 at 12:04
  • `${myReport}` is not valid JavaScript syntax. If this is part of the framework you are using and it's replaced by an actual value before being parsed as JS, then please post an example of the value. It could be that the *value* is not in the right format (since it would also have to be valid JS in this case). – CherryDT Jul 12 '16 at 12:05
  • If you want to build template strings, you need back-ticks (see https://developers.google.com/web/updates/2015/01/ES6-Template-Strings?hl=en ) but here `body = myReport;` would be simpler. – Denys Séguret Jul 12 '16 at 12:05
  • It looks like JavaScript is trying to interpret `${myReport}` directly, and it's not correct JavaScript. If something is supposed to pre-process that, it's not happening. – Pointy Jul 12 '16 at 12:05
  • I should clarify that I'm writing the scriplet directly inside Operations Orchestration Studio 9, which is equipped to handle the ${myReport} variable. ${myReport} is just a simple string defined elsewhere in the flow. It may as well say "This is a report." – Martin Erlic Jul 12 '16 at 12:07
  • Where does the complaint come from ? If it's in a browser, then what's the code received by the browser ? – Denys Séguret Jul 12 '16 at 12:07
  • I figured it out. Since ${myReport} is a string, I need to include it within the quotation marks, i.e. body = "${myReport}". Sorry for the strange question. – Martin Erlic Jul 12 '16 at 12:10
  • The code is compiled in an HP-specific scriplet IDE. I figured it out. Since ${myReport} is a string, I need to include it within quotation marks, i.e. body = "${myReport}". Sorry for the obscure question. Would be nice to open an Operations Orchestration forum on SO. – Martin Erlic Jul 12 '16 at 12:14
  • @bluemunch I have tagged your question with "operations-orchestration". You should be able to add your own tags (when you're sure they're relevant) with the number of rep points you have. – JLRishe Jul 12 '16 at 12:34
  • @JLRishe Thank you. I appreciate that. I'm sure there are people who would be interested in asking questions and contributing. – Martin Erlic Jul 12 '16 at 12:36

1 Answers1

1
myBody = body;
if (!myBody || myBody.length === 0) {
    body = "There are currently no unassigned servers to report.";
} else {
    body = "${myReport}";
}

Flow variables in HP OO 9 are strings, so the value must be included within a set of quotation marks.

Martin Erlic
  • 5,467
  • 22
  • 81
  • 153