UI Macro GlideRecord Functionality
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2014 10:10 AM
Hello All,
I'm working on a UI Macro that should run a function when it is clicked. This function is supposed to go to the user record and modify a field. It's NOT working that way. The UI Macro is having values passed to it from Jelly scripting in a Dynamic Content block. I know the values being passed into it are accurate because if I do a gs.print and insert the Jelly variable names, it prints the correct data onto the screen. So in that Dynamic Content block, I invoked the UI Macro I wanted and passed the jelly parameters into it. I know the parameters are being passed correctly because one of them is a title value that I modified in the Dynamic Content block. When I do that, the UI Macro shows up with the new information. So my data that I am passing in is accurate. I created a function using <script> tags in the UI Macro. This is a standard GlideRecord function but it's not doing anything. I've tried using the JEXL expressions in the query and I've tried jelly.jvar_variable_name and neither one give the desired results. Does anyone know how to run a GlideRecord query from a UI Macro using Jelly Variables?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-19-2014 02:00 PM
HI,
You could do something like the below code in your UI Macro
<g:evaluate jelly="true">
var testgr = new GlideRecord("test_Table");
testgr.addQuery("sys_id",jelly.sysparm_sys_id);
testgr.query();
</g:evaluate>
Hope this helps.
-Aman
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2014 04:59 PM
This didn't actually fix my problem but definitely pointed me in that direction. So that problem is resolved but it did lead to another problem. Now that I have the functionality I wanted, The 'Status' does not show the way I need it to. So here is the layout...
- Name -
- Status -
- Integer Value -
- Integer Value -
- Integer Value -
- UI Macro to change status -
When I go to Content Management module and click the page and then click 'Edit Page', the 'Status' value shows like I need it and it updates at refresh like I need it. The problem is then, if I click 'Preview Page', it opens in a separate window with the URL /cms/page_name. When it actually opens as a CMS page, the script does not appear to function. Any idea why the javascript does not function on a CMS page? Below is the script...
<j2:if test="$[!jvar_tlgarrett_status]">
<script>
document.getElementById("stat").innerHTML = "Not Available";
document.getElementById("stat").style.color = "red";
</script>
</j2:if>
I know the value of $[jvar_tlgarrett_status] equates to TRUE which should set the 'Status' field above to 'Not Available' in red lettering. Again, this works when I 'Edit Page' but not when I 'Preview Page'.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-07-2021 01:58 PM
jelly.sysparm_sys_id --- what does this display? is it a sys id of a logged in user?