Default values for Text Prompts
Best Answer
-
Roland_Kind Partner Advanced IT Monkey ✭✭✭Hi,
this is not a final solution for your problem - but it might be helpful to create one.
This will set text values on RO which are given in the requesting URL, but the approach might be useful for solving your problem (bold text is important part) - and of course maybe better approaches are available
<span class="post-font-size-medium"> //second part will be the options string --> further split by "&"</span>
<span class="post-font-size-medium"></span>
<span class="post-font-size-medium"><br> if (urlOptions.length == 2)<br> { </span>
<span class="post-font-size-medium"> splitUrlOptions = urlOptions[1].split("&"); <br> var urlOptionsDictionary = {};<br> var urlOptionsArray=[];</span>
<span class="post-font-size-medium"> for (i = 0; i < splitUrlOptions.length; i++) { <br></span>
<span class="post-font-size-medium"> keyValuePair=splitUrlOptions[i].split("=");<br> urlOptionsDictionary[keyValuePair[0].toLowerCase()]=keyValuePair[1];<br> urlOptionsArray[i]=keyValuePair[1];<br> } <br> <br> qcontainer=$('.question-container > .col-md-6') // get RO questions<br> <br> for (i = 0; i < qcontainer.length; i++) { <br> prompt=qcontainer[i].children[0].outerText.split(" ")[0].toLowerCase() <br> if (prompt in urlOptionsDictionary) // true if "key" exist in object<br> {<br> <b>qcontainer[i].children[1].children[1].value=urlOptionsDictionary[prompt];</b><br><b> qcontainer[i].children[1].children[2].value=urlOptionsDictionary[prompp]; </b> <br> }<br> } <br> }<br> }</span>
<span class="post-font-size-medium">function RKUpdateRO()<br> {<br> var urlOptions= window.location.href.split("?"); </span>gives the following result:
hope this helps
5
Answers
I'm not too sure if i'm understanding. You are not asking about making a prompt required, right? What scenario do you have that you're trying to do?
Have a drop-down - Employee or Vendor.
For some inane reason, the form owner wants the next field to be Company.
If Vendor, then Company is blank.
If Employee, then have the text, "Acme" in the Company field. But still allow it to be overwritten.
What you're describing sounds doable with a Simple List (which translate to strings/text) so you're Simple List would contain "Employee or Vendor" this you could set a default value on. Then with ARO you can optionally display the Company name and make it a mandatory field. If an employee, with runbook automation you just set the Company name behind the scenes rather than solicit the input.
to get this to be dynamically populated i would suggest that you have two company fields in your form one that is blank and one that is using @placeholder and then use the advance request offering function to show one when Employee and one when vendor, once you have done this use the multiple mapping to add both fields to one text box in the SR since only one can be filled out dependent on the selection above
I then examined the field and found it to be a TextArea type input as defined below:
<textarea class="k-textbox k-invalid input-ro form-control input-sm" id="textArea7186d4ed-7933-4757-94a0-864893f162ee" onkeyup="matchValues('7186d4ed-7933-4757-94a0-864893f162ee');" onpaste="pasteValue('7186d4ed-7933-4757-94a0-864893f162ee');" maxlength="2147483647" rows="1"></textarea>
I can't inject text between the tags as is the typical answer and I haven't found a js snippet that will set the text even when I hard-code the id. Granted my javascript skills are rusty.
this is not a final solution for your problem - but it might be helpful to create one.
This will set text values on RO which are given in the requesting URL, but the approach might be useful for solving your problem (bold text is important part) - and of course maybe better approaches are available
gives the following result:
hope this helps