- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 03:06 PM
I have the need to display on a catalog item a list of details from records in a table, so I'm attempting to write a macro. In order to retrieve the records, I need to know the value of another variable on the form. In this example, I have a variable called "position" and I want to get its sys_id so that I can then find records in another table (u_required_item) and print the names and details on the form. I've tried quite a few things I found online, all to no success. This is the current script which is also not working. The printed output is just "Output: ()." So, it's obvious I'm not getting the value from the variable "position".
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<j2:set var="jvar_position" value="$[current.getValue('position')]"/>
Output: ($[jvar_position]).
</j:jelly>
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 07:30 AM
So, I think I've passed in what I need to do my coding. It's not ideal necessarily, there might be a cleaner way, but this is what I ended up doing (following the correct answer on this community post: pass value from variable to UI macro )
This is the 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 type="text" id="position_id" name="position_id" value=""/>
<script>
function setPosition(text){
$j("#position_id").val(text);
}
</script>
</j:jelly>
On the form, I created two client scripts, one onLoad (because the form can inherit the value from an order guide) and one onChange of the Position field.
onLoad:
function onLoad() {
setPosition(g_form.getValue('position'));
}
onChange:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
setPosition(newValue);
}
And now I'm finally getting the sys_id in a field (I'm going to hide it, the user doesn't need to see it, I just need it for scripting).

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2017 09:34 PM
Hi Kristen,
What do you get when you try accessing the current object directly (no j:set)
Output: ${current.getValue('position')}.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 06:43 AM
I get no value:
Current script:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!--<j2:set var="jvar_position" value="$[current.getValue('position')]"/>-->
Output: ${current.getValue('position')}.
Output: ($[jvar_position]).
</j:jelly>
Output:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 06:46 AM
Just to check the obvious... are you sure the field is position and not u_position?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-26-2017 06:48 AM
I just double checked and it is called "position".