(uCMDB-SM integration) How fill null fields with a default value during a ucmdb-sm data push (511 Views)
Reply
Occasional Advisor
EfsyEngi
Posts: 14
Registered: ‎07-24-2013
Message 1 of 2 (511 Views)
Accepted Solution

(uCMDB-SM integration) How fill null fields with a default value during a ucmdb-sm data push

Hello there,

 

Our recent project requires me to fill blank fields in SM records with a "No uCMDB data exists" string when uCMDB pushes a null attribute to SM.

 

I've been focusing my efforts on adjusting the XSLT file,  using xsl:choose and xsl:if to test for a blank attribute value and basing . None of my efforts have succeeded fully - in some cases, the test succeeds for CIs with attributes with valid values but does nothing for CIs with null attributes. In other cases, the null value checks mark my Good CI as null or pushes nothing at all for any CI, good or bad.

 

Here are 2 examples, among many, of the attribute mappings I've attempted to use. 

<xsl:for-each select="@description">
                    <xsl:variable name="description" select="."/>
                    <xsl:choose>
                        <xsl:when test="$description=not('')"><Description><xsl:value-of select="$description"/></Description></xsl:when>
                        <xsl:otherwise><Description>This field has no data in uCMDB</Description></xsl:otherwise>                        
                    </xsl:choose>
                </xsl:for-each>

 

<xsl:for-each select="@description">
                    <xsl:variable name="description" select="."/>
                    <Description><xsl:value-of select="$description"/></Description>
                    <xsl:if test="$description = ''"><Description>This field has no data in uCMDB</Description></xsl:if>
                </xsl:for-each>

 These above attribute mappings test for a blank value in the variable, which in turn should trigger the null condition and insert a "This field has no data in uCMDB" string. I've tried a direct check for a blank value, using @description with no variable, but the result is still the same.

 

I'm aware of these null value connotations in XSLT:
' '

not(string(.))

not(normalized-space(.))

 

Are there any other changes I can make to the XSLT, or will I have to go into SM and make changes to the form, format control, WSDL object, etc.? If so, any suggestions on how to proceed would be excellent - Thanks for your time, everyone.

Occasional Advisor
EfsyEngi
Posts: 14
Registered: ‎07-24-2013
Message 2 of 2 (473 Views)

Re: (uCMDB-SM integration) How fill null fields with a default value during a ucmdb-sm data push

Solved.

 

I was on the right track with a xsl:if test, but I wasn't applying it in the correct order.

 

                <xsl:for-each select="@description">
                    <Description><xsl:value-of select="."/></Description>
                </xsl:for-each>
                <xsl:if test="not(normalize-space(@description))">
                    <Description>No uCMDB Data</Description>
                </xsl:if>

By using a separate <xsl:if> instead of a <xsl:choose> statement, debugging is a matter of removing the new lines.

 

Hope this helps everybody.

The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.