- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:28 AM
I have a Record Producer variable of type Custom. It uses a Widget to create a Texarea input tag .
I need to get the value entered into the TextBox and map it to a field on the target record in Record Producer main script. Here g_form.getValue doesn't help as its a custom variable.
Kindly share if it is achievable. If yes, then how?
Thanks in advance.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:47 AM
see this working example, please enhance it further
I hope I answered your question
Widget HTML:
<div>
<label for="customTextArea">Enter your text:</label>
<textarea id="customTextArea"
class="form-control"
ng-model="textValue"
rows="5"
placeholder="Type here..."></textarea>
</div>
Client controller:
api.controller = function($scope) {
/* widget controller */
var c = this;
// Watch for changes and update the variable
$scope.$watch('textValue', function(newVal, oldVal) {
if (newVal !== oldVal) {
// Update the catalog variable value
var g_form = $scope.page.g_form || window.g_form;
if (g_form && g_form.setValue) {
g_form.setValue('application_type', newVal);
}
}
});
};
Output: it adds value to the string variable, you just hide it
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2025 09:31 AM
it works fine, see below.
I used catalog UI policy to hide that variable and also using setValue() from widget to set the variable
Then once RITM is generated the value is still present in that single line text variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:39 AM
that's not going to work
You will have to do this
1) create a string type variable and hide it in your catalog item
2) then in that widget text area use client controller to observer the change and set the value entered into that text area into the hidden variable and then you can access it
Pass values from a Widget to a Catalog item variable
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 06:47 AM
see this working example, please enhance it further
I hope I answered your question
Widget HTML:
<div>
<label for="customTextArea">Enter your text:</label>
<textarea id="customTextArea"
class="form-control"
ng-model="textValue"
rows="5"
placeholder="Type here..."></textarea>
</div>
Client controller:
api.controller = function($scope) {
/* widget controller */
var c = this;
// Watch for changes and update the variable
$scope.$watch('textValue', function(newVal, oldVal) {
if (newVal !== oldVal) {
// Update the catalog variable value
var g_form = $scope.page.g_form || window.g_form;
if (g_form && g_form.setValue) {
g_form.setValue('application_type', newVal);
}
}
});
};
Output: it adds value to the string variable, you just hide it
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-19-2025 08:25 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-21-2025 09:14 AM
Hi @Ankur Bawiskar
Thanks much for a detailed response.
But the issue here is the hidden field. Do you think g_form.setValue would work on a hidden field?
Kindly share your thoughts.
Regards,
Sameekshya