I previously worked with someone to have text added to a resource question in the rest API. The solution given is working well as long as text is manually added by the requester. For example the following script:
var current = $CS.getValue("RES_601_QUS_301");
var modified = current+" "+"key"+":"+"hostname";
if($CS.isFormSubmit()){
$CS.setText("RES_601_QUS_301", modified);
}
...gives me:
},
"qstn_text_301": {
"value": "VM1 key:hostname"
...which is exactly what I need.
However, what I have discovered is that, if the resource question is a dropdown box with multiple choices, I cannot figure out how to get the text added to the rest API. For example, this section of script:
var current = $CS.getValue("RES_601_QUS_604");
var modified = current+" "+"key"+":"+"OS";
if($CS.isFormSubmit()){
$CS.setText("RES_601_QUS_604", modified);
}
...returns this if I select one choice in the dropdown:
"qstn_select_604": {
"name": "rhel8",
"id": "909"
},
If I make a different choice, this is returned:
"qstn_select_604": {
"name": "rhel9",
"id": "910"
},
As I hope you can see, the result is different based on the choice but what I'm trying to show in the rest API (key:OS) is not working. I suspect it's a syntax error in my script but I cannot figure out the correct syntax.