How can I use a custom form as a script parameter?
# ask-stanley-ai
s
How can I use a custom form as a script parameter?
c
AI generated answer (using internal Slack threads):
To use a custom form as a script parameter, you can append
&cf=(internal id of form)
to the URL. This will allow the specific form to be applied. However, if you want to change the form that is loaded using a script, you can use a
beforeLoad
user event script. However, keep in mind that the form has already been chosen by the time of the
beforeLoad
. Here is an example of how you can do this:
Copy code
javascript
if(category == 3) {
  record.setValue({
    fieldId: 'customform',
    value: '105',
  });
} else {
  record.setValue({
    fieldId: 'customform',
    value: '167',
  });
}
If this doesn't work, you can redirect the user using
N/redirect
. Alternatively, you could also do it in
pageInit
in a client script, but that'll force a refresh so the redirect is a better user experience. With the redirect, you should be able to add a
cf
parameter in the URL for the custom form. If you want to get the 'customform' scriptId, it's not directly accessible. You may have to come up with a workaround, using a custom record or something similar. The only thing you can do with that is
&xml=t
. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.836838365
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83548975
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.83156985
Please provide your feedback on this answer.