- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Hi All,
I have a catalog item where there are 2 variables - article_name and article_name2.
article_name2 is a read only variable (single line text)
article_name is a single line text variable.
When the users fills in the article_name variable, I want the system to automatically populate article_name2 with the same information.
I have tried the following as a catalog client script, but it doesn't populate the field:
function onSubmit() {
var articleName = g_form.getValue('article_name');
if (articleName) {
// Set the value of the variable
g_form.setValue('article_name2', articleName);
}
return true;
}Is anyone able to help me achieve this?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday - last edited Tuesday
Hi,
I would start by changing the logic to happen as an onChange Client script (have it interact on change of the first variable article_name).
Then the user can see the results before the form is submitted.
and in the script you would only need to do the setValue-part, and use the newValue input as basis, like this:
g_form.setValue('article_name2', newValue);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday - last edited Tuesday
Hi,
I would start by changing the logic to happen as an onChange Client script (have it interact on change of the first variable article_name).
Then the user can see the results before the form is submitted.
and in the script you would only need to do the setValue-part, and use the newValue input as basis, like this:
g_form.setValue('article_name2', newValue);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
Thank you, but unfortunately, that didn't work. I updated in to an onChange script and entered as below
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
//Type appropriate comment here, and begin script below
g_form.setValue('article_name2', newValue);
}Is this script correct?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Tuesday
The script looks correct, assuming your variable name actually is "article_name2".
Did you also set the Variable name option on the client script?
It should trigger onchange of your first variable, the one you are copying text from.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago
Well, I was silly - I had it all correct but I had left the UI Type to the default of Desktop - change it to All and we were cooking!
Thank you for your help!
