Help: catalog item ui macro contents not displaying in catalog item on CMS page

kevinanderson
Giga Guru

I am in the process of rebuilding our CMS portal. To get a more elegant presentation, we are attempting to integrate the catalog items into an iframe on our cms home page to give a Single Page Application feel to our CMS. I am having an issue getting the existing catalog detail content blocks to function with my new layout, so I extracted the catalog item and catalog guide iframe links and call them directly from our CMS via client side jquery scripts.

The catalog items contain a variable set names customer info, that has a macro on it to add tabbed content to the catalog item description area. When calling the catalog items directly via com.glideapp.servicecatalog_cat_item_view.do from a script, I am unable to see the macro "catalog_item_tabs" contents in the catalog item that render in our revised cms


Currently in our CMS, we have a dynamic block that loads the catalog items into the cms layout.   Looking at the script and screenshots below, does anyone have an idea why the variable set macro doesn't display when I call the catalog item direct with the com.glideapp function?


Macro - catalog Item

<?xml version="1.0" encoding="utf-8" ?>

<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">

      <g2:evaluate jelly="true">

              var cartContinueShopTargetKey = GlideappCatalogURLGenerator.getBrowsingContextTargetKey();

              var cartContinueShopTargetValue = GlideappCatalogURLGenerator.getBrowsingContextTarget();

      </g2:evaluate>

      <j2:if test="$[!(typeof cartContinueShopTargetValue == 'undefined' || cartContinueShopTargetValue == null || cartContinueShopTargetValue == '')]">

              <input type="HIDDEN" id="$[cartContinueShopTargetKey]" value="$[cartContinueShopTargetValue]" />

      </j2:if>

      <g2:evaluate jelly="true">

              var cartContinueShopKey = GlideappCatalogURLGenerator.getBrowsingContextCategorySysID();

              var cartContinueShopValue = GlideappCatalogURLGenerator.getContinueShoppingUrl(jelly.sysparm_catalog, jelly.sysparm_catalog_view);

      </g2:evaluate>

      <j2:if test="$[!(typeof cartContinueShopValue == 'undefined' || cartContinueShopValue == null || cartContinueShopValue == '')]">

              <input type="HIDDEN" id="$[cartContinueShopKey]" value="$[cartContinueShopValue]" />

      </j2:if>

      <input type="HIDDEN" id="sysparm_no_checkout" value="$[sysparm_no_checkout]" />

      <input type="HIDDEN" id="sysparm_facade_table" value="$[sysparm_facade_table]" />

      <input type="HIDDEN" id="sysparm_facade_sys_id" value="$[sysparm_facade_sys_id]" />

      <input type="HIDDEN" id="sysparm_processing_hint" name="sysparm_processing_hint" value="$[sysparm_processing_hint]" />

  <input type="HIDDEN" id="sysparm_catalog" name="sysparm_catalog" value="$[sysparm_catalog]" />

      <input type="HIDDEN" id="sysparm_catalog_view" name="sysparm_processing_hint" value="$[sysparm_catalog_view]" />

      <input type="HIDDEN" id="sysparm_link_parent" name="sysparm_link_parent" value="$[sysparm_link_parent]" />

      <input type="HIDDEN" id="sysparm_id" value="$[sysparm_id]" />

      <g2:inline template="output_messages.xml" />

      <j2:set var="jvar_id" value="$[sysparm_id]" />

      <j2:set var="jvar_cart_edit" value="$[sysparm_cart_edit]" />

      <g2:evaluate jelly="true">

              var header_label = null;

              if (jelly.jvar_cart_edit) {

                      item_guid = jelly.jvar_cart_edit;

                      header_label = gs.getMessage('catalog_cart_item');

              } else

                      item_guid = gs.generateGUID('');

              sc_cat_item = new GlideRecord('sc_cat_item');

              sc_cat_item.get(jelly.jvar_id);

              if (!new CatalogItemTypeProcessor().canCreateNormalCartItem(sc_cat_item.sys_class_name)) {

                      sc_cat_item_producer = new GlideRecord('sc_cat_item_producer');

                      sc_cat_item_producer.get(jelly.jvar_id);

                      item_table = sc_cat_item_producer.table_name;

              } else

                      item_table = "sc_cart_item";

      </g2:evaluate>

      <j2:if test="$[sysparm_preview != 'true']">

              <g:inline template="com.glideapp.servicecatalog_context_menu.xml" />

      </j2:if>

      <input type="HIDDEN" id="no_proceed_checkout" value="$[sc_cat_item.no_proceed_checkout]" />

      <input type="HIDDEN" id="ni.attachment_target" value="$[item_table]" />

      <input type="HIDDEN" id="sysparm_item_guid" name="sysparm_item_guid" value="$[item_guid]" />

      <j2:if test="$[sysparm_link_parent == null || sysparm_link_parent == '']">

              <g:evaluate var="cat_id" jelly="true">

                      var cat_id = '';

                      var cat_item = GlideappCatalogItem.get(jelly.sysparm_id);

                      if (cat_item)

                              cat_id = cat_item.getFirstAccessibleCategoryForSearch();

                      cat_id;

              </g:evaluate>

              <j2:set var="sysparm_parent" value="$[cat_id]" />

      </j2:if>

      <j2:if test="$[sysparm_link_parent != null and sysparm_link_parent != '']">

              <j2:set var="sysparm_parent" value="$[sysparm_link_parent]" />

      </j2:if>

      <j2:if test="$[sysparm_headless != 'true']">

              <g2:evaluate var="sysparm_use_search" jelly="true">

                      var sysparm_use_search = true;

                      if (!new CatalogItemTypeProcessor().canShowSearchField(sc_cat_item.sys_class_name))

                              sysparm_use_search = false;

                      if (sc_cat_item.no_search)

                              sysparm_use_search = false;

                      sysparm_use_search;

              </g2:evaluate>

              <!-- caption -->

              <table class="wide" cellspacing="0" cellpadding="0" width="100%">

                      <g2:sc_header useAddButton="false"

                                                  search="$[sysparm_search]"

    catalog="$[sysparm_catalog]"

    view="$[sysparm_view]"

    catalogView="$[sysparm_catalog_view]"

    processingHint="$[sysparm_processing_hint]"

    category="$[sysparm_parent]"

    noCheckout="$[sysparm_no_checkout]"

    isSearch="false"

    ignore="true"

    isItem="true"

    isBrowse="false"

    useSearch="$[sysparm_use_search]"

                                                  st="false"

    isPreview="$[sysparm_preview]"

    contextId="$[sysparm_id]"

    contextClass="$[sc_cat_item.sys_class_name]"

    contextName="$[sc_cat_item.name.getDisplayValue()]"

    contextTable="$[item_table]"

    headerLabel="$[header_label]"

    currentRow="$[sysparm_current_row]"

                                                  baseForm="$[sysparm_base_form]" />

              </table>

      </j2:if>

      <g:catalog_cart_attachment_list />

      <!-- description, etc -->

      <table id="item_table" cellSpacing="0" cellPadding="0" border="0" width="100%">

              <tr>

                      <td valign="top" width="100%" style="padding-left: 5px; padding-right: 5px;">

                              <!-- item caption -->

                              <table width="100%" style="border-collapse: collapse;">

                                      <tr>

                                              <td width="100%" style="border-spacing: 0px; padding: 5px 0px 0px 0px;">

                                                      <table cellspacing="0" cellpadding="0" width="100%">

                                                              <tr class="io_label">

                                                                      <td style="padding-left: 10px;">

                                                                              $[NS:sc_cat_item.short_description.getDisplayValue()]

                                                                      </td>

                                                              </tr>

                                                              <tr>

                                                                      <td colspan="2" class="catalog_description" style="padding: 2px; padding-top: 10px; list-style-position: inside;">

                                                                              <g2:evaluate var="jvar_has_image" jelly="true">

                                                                                      var image_src = sc_cat_item.picture.getDisplayValue();

                                                                                      if (jelly.sysparm_staged_image_id != '') {

                                                                                              var stagedItemGR = new GlideRecord('sc_ic_item_staging');

                                                                                              stagedItemGR.addQuery('sys_id', jelly.sysparm_staged_image_id);

                                                                                              stagedItemGR.query();

                                                                                              if (stagedItemGR.next())

                                                                                                      image_src = stagedItemGR.desktop_image.getDisplayValue();

                                                                                      }

                                                                                      var has_image = true;

                                                                                      if (image_src == null || image_src == '')

                                                                                              has_image = false;

                                                                                      has_image;

                                                                              </g2:evaluate>

                                                                              <table style="border-collapse: collapse; width: 100%;" padding="0" border="0" margin="0">

                                                                                      <tr>

                                                                                              <j2:if test="$[jvar_has_image]">

                                                                                                      <td style="vertical-align: top;">

                                                                                                              <div style="padding:0px 4px 0px 0px">

                                                                                                                      <img class="sc_cat_item_image" src="$[image_src]" alt="$[NS:sc_cat_item.description]"></img>

                                                                                                              </div>

                                                                                                      </td>

                                                                                              </j2:if>

                                                                                              <td style="vertical-align: top; width: 100%;">

                                                                                                      <g2:no_escape>$[NS:sc_cat_item.description]</g2:no_escape>

                                                                                              </td>

                                                                                      </tr>

                                                                              </table>

                                                                              <j2:if test="$[sysparm_preview != 'true']">

                                                                                      <g2:catalog_item_additional_cats />

                                                                              </j2:if>

                                                                      </td>

                                                              </tr>

                                                      </table>

                                              </td>

                                      </tr>

                              </table>

                              <g2:evaluate var="jvar_exists">

                                      var templateName ='com.glideapp.servicecatalog_' +

                                      sc_cat_item.sys_class_name + '.xml';

                                      gs.templateOrMacroExists(templateName);

                              </g2:evaluate>

                              <j2:choose>

                                      <j2:when test="$[sc_cat_item.type == 'package']">

                                              <g:macro_invoke macro="catalog_package_display" silent_warnings="true" />

                                      </j2:when>

                                      <j2:when test="$[jvar_exists]">

                                              <g2:inline template="$[templateName]" />

                                      </j2:when>

                                      <j2:otherwise>

                                              <g:inline template="com.glideapp.servicecatalog_item_or_bundle.xml" />

                                      </j2:otherwise>

                              </j2:choose>

                      </td>

                      <!-- cart -->

                      <td valign="top" id="order_and_cart_v2">

                              <j2:if test="$[sysparm_catalog_mode == 'form_facade']">

                                      <g2:inline template="sc_cart_facade.xml" />

                              </j2:if>

                              <j2:if test="$[sysparm_catalog_mode != 'form_facade']">

                                      <j2:choose>

  <j2:when test="$[sc_cat_item.sys_class_name == 'sc_cat_item_producer' || sc_cat_item.sys_class_name == 'sc_cat_item_producer_service' || sc_cat_item.sys_class_name == 'sc_cat_item_content' || sc_cat_item.sys_class_name == 'sc_cat_item_service']">

                                                      <!-- no cart for producers ... their submit is down below no cart at all for content pages -->

                                              </j2:when>

                                              <j2:otherwise>

                                                      <j2:if test="$[!sc_cat_item.custom_cart.nil()]">

                                                              <g2:macro_invoke macro="$[NS:sc_cat_item.custom_cart.name]" />

                                                      </j2:if>

                                                      <j2:if test="$[sc_cat_item.custom_cart.nil()]">

                                                              <g2:evaluate var="jvar_use_cart_layouts" jelly="true">

                                                                      var jvar_use_cart_layouts = new SNC.ServiceCatalogLayoutService().useSCLayout();

                                                                      if (jvar_use_cart_layouts == true)

                                                                              jvar_use_cart_layouts = sc_cat_item.use_sc_layout + '';

                                                                      else

                                                                              jvar_use_cart_layouts = 'false';

                                                                      jvar_use_cart_layouts;

                                                              </g2:evaluate>

                                                              <j2:if test="$[jvar_use_cart_layouts == 'false']">

                                                                      <g2:catalog_cart_default />

                                                              </j2:if>

                                                              <j2:if test="$[jvar_use_cart_layouts == 'true']">

                                                                      <g2:catalog_cart_v2 />

                                                              </j2:if>

                                                      </j2:if>

                                              </j2:otherwise>

                                      </j2:choose>

                              </j2:if>

                      </td>

              </tr>

      </table>

      <j2:if test="$[SNC.CatalogCMS.isCMSSite() == true]">

              <script>

                      var div = $(cel("div"));

                      var table = $("item_table");

                      table.replace(div);

                      div.insert({ top: table });

                      div.style.overflowX = "auto";

              </script>

      </j2:if>

      <j2:if test="$[sc_cat_item.sys_class_name == 'sc_cat_item_producer' || sc_cat_item.sys_class_name == 'sc_cat_item_producer_service']">

              <g2:inline template="producer_buttons.xml" />

      </j2:if>

      <g2:client_script type="catalog_item" catalogItem="$[sysparm_id]" />

      <j2:set var="jvar_catalog_item" value="$[sysparm_id]" />

      <g:inline template="catalog_ui_policy.xml" />

</j:jelly>




Capture_macro fail1.PNG


Capture_macro fail2.PNG



Capture_macro fail3.PNG



1 ACCEPTED SOLUTION

kevinanderson
Giga Guru

According to Brian Alson with Professional Services,   the issues is the sub domain that the page com.glideapp.servicecatalog_cat_item_view.do is executed from.


Macros will not execute from the service now root url, and will only execute when the catalog item is rendered from within a CMS subdomain.   Adding my CMS subdomain to the iframe   url path fixed the issue:



<service now url>/MY_CMS/>com.glideapp.servicecatalog_cat_item_view.do?params=...


View solution in original post

4 REPLIES 4

Valor1
Giga Guru

What happens when you remove the "com.glideapp." from the UI Macro reference?


Brian Alson from ServiceNow noticed that the macro doesn't load in servicenow UI either.   It appears that I have to dig deeper into the catalog item scripts and extract the contents that are expanding in the CMS.   I have a meeting on Monday to determine exactly what needs to be done and I'll update when i learn more.   Thanks


kevinanderson
Giga Guru

According to Brian Alson with Professional Services,   the issues is the sub domain that the page com.glideapp.servicecatalog_cat_item_view.do is executed from.


Macros will not execute from the service now root url, and will only execute when the catalog item is rendered from within a CMS subdomain.   Adding my CMS subdomain to the iframe   url path fixed the issue:



<service now url>/MY_CMS/>com.glideapp.servicecatalog_cat_item_view.do?params=...


Facing a similar issue for wizards. I have a UI macro variable in Wizard which is not displaying in CMS page. Any thoughts?