how to call a ui macro from on change client script which(UI macro) should create dynamic input text fields based on input form variable ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2016 07:20 AM
Still there are many questions unanswered even after searching community ?
1. How can we call UI macro from client script? can any one help me with syntax ?
(as said in one community post .. calling required function in ui macro but this is not actaully working)
2. Is there a posibility to create dynamic input fields based on any input of a catalog form , if so how can we do that. i.e lets say if i want to create multiple users using catalog request , i will provide number of users to add.Let's Say 6 so the macro should dynamically create a from which should have 6 fields !..
How can we achieve this scenario ??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2021 07:55 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2021 08:04 AM
Hi,
inside the UI macro function you can get the MRVS row as json string using g_form.getValue('mrvsVariableName')
Parse it and then add up and then use g_form to set the other variable
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-12-2021 07:11 PM
Thank Ankur.That worked.
Hi Ankur,
Do you know how do i call function in the onLoad Client Script from a macro. I have button that is showing in the RITM, on click of that button i want the function in onLoad Script to trigger and do calculation from a column Multi row variable set and update a field in the catalog item.
UI Macro
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<input id="calc" type="button" value="Calculate Total Area" onclick="xyz();" />
<script>
function xyz(){
javascript:alert('Hi');
calcTotal();
}
</script>
</j:jelly>
onLoad Script
function onLoad() {
//Type appropriate comment here, and begin script below
}
function calcTotal() {
var mrvs = this.my_g_form.getValue('area_allocations');
var objList = JSON.parse(mrvs);
for (var i = 0; i < objList.length; i++) {
calculatedArea += parseFloat(objList[i].allocated_area);
}
g_form.setValue('total_allocated', calculatedArea);
}