UI Macro - how to get <g2:evaluate> to work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 11:53 AM
I am working through an issue to embed a workflow stage in a UI Macro. I have hit a roadblock with the call to item_workflow.xml. For some reason none of the g2:evaluate tags on the UI macro seem to evaluate.
The original thread is here: CMS - How to embed a workflow stage list in a table
Trying to call the following code:
<g:inline template="item_workflow.xml" />
Instead of the expected HTML element in the page, I see what I assume is the contents of the xml file eferenced in the <g:inline> statement, which is:
<g2:evaluate expression="'sc_req_item.stage'" var="jvar_ref"></g2:evaluate>
<g2:evaluate expression="sc_req_item.stage.getGlideRecord().sys_id" var="jvar_id"></g2:evaluate>
<g2:evaluate expression="RendererFactory.getRenderer('sc_req_item.stage', '$[jvar_id]')" var="jvar_rend"></g2:evaluate>
<g2:macro_invoke workflow_id="$[jvar_id]" ref="$[jvar_ref]" macro="$[jvar_rend]"></g2:macro_invoke>
As a test, I added the following simple code to the page to see if any g2 tags are gettign evaluated:
<g2:evaluate var="jvar_g2_test">
var test = "test";
test;
</g2:evaluate>
$[jvar_g2_test]
which outputs directly on the page:
Can anyone provide insight as to why these g2 tags do not seem to be getting evaluated?
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-29-2015 09:30 PM
I'm going to assume since your previous post has "CMS" in the title that you are bringing in the macro and your g2 statements within a Dynamic Content Block on the CMS side and not a UI Page. If this is true then on the Dynamic Content Block form you'll need to check the "Two phase" check box.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2015 06:18 AM
Chris,
Thanks for your reply. My understanding of the hierarchy of the page configuration is as follows:
- Content Management -> Pages -> search for the target page title
- Pages (click the target page title) -> Related Links -> click "edit page"
- Inside the page, click the module to be edited
- Content Block Lists -> Type = "data table list" (UI Macro)
So I do not belive that a dynamic block is being used in the currect configuration. I assume that is a limiting factor on the feature I am attempting to implement. When I attemp to open the Content Block List for "data tables list", there is no option for second stage processing.
Do content block lists only process the first phase? Do I need to some how wrap the UI macro in a dynamic block? Any suggestions on how to bring these pieces together would be helpful. Much thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-01-2015 11:01 AM
Kevin,
No, you don't have to wrap this in a Dynamic Content block. I only mentioned that because I was unsure where your code was sitting. I'm not positive on why phase2 doesn't work when in a List Macro but it may be that since the list is actually controlled by the system it doesn't need to use two phases. The List definition is simply a way of putting a UI to the output which at that time the current value would already be given; no need to have anything cached. (Don't quote me on that. It's just my assumption).
From the looks of it, it seems like you're trying to build another list from a list. I think I would try one of two things.
1) Try your scripts all in phase 1.
or
2) Use the advanced feature of the content block list. The advanced feature will allow you to script your list instead of using the query builder. And then construct your list definition accordingly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-02-2015 09:13 AM
Brian Alson with ServiceNow indicated that within the CMS, G2 and J2 tags do not evaluate, except inside dynamic blocks.
The solution was to migrate the XML code from the the List Block, to a Dynamic Block, and update the code to remove all calls to "current". The solution is more fully documented here: CMS - How to embed a workflow stage list in a table