This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Can't get the If statement to work in a notification.

Hello,

I'm trying to have my notification template use an if statement. What am I doing wrong? The code is reading the variable.

This is my test code:

The Platform is :$FIELDVALUE(Platform)

$IF(Platform, M8)

This is an M8 Install.

$ELSE()

This is not an M8 Install.

$ENDIF()

*****************************************************************************************************************************

Output is:

The Platform is:M8

This is not an M8 install.

'************************************************************************************************************************8

The output is incorrect as far as I'm concerned.

Is this something I need to do to make the the if statement work?

Regards,

WIll

  • 0
    $IF(Platform, M8)

    I'm not familiar with that syntax for the "$IF" tag.  Which version of SBM is that? Can you point me to a user guide??

  • 0 in reply to 

    https://docs.microfocus.com/doc/Solutions_Business_Manager/12.1/ttwa_notification_tags   We are on version 12.1. This is the first time I've attempted the if.

  • 0 in reply to 

    What are the "Platform" and "M8" values??  The "$IF()" tag has a specific set of things it can do.  AFAIK, comparing Fields and values is not one of them, except for the ITEMTYPE field.

  • 0 in reply to 

    Thank you for your help. The platform field has values of "M5" or "M8". Its just a random single selection field. Ok, if your saying it will only work with ITEMTYPE I can live with that. I attempted the same exercise with ITEMTYPE field however I'm confused. Is the "ITEMTYPE" field now "ISSUETYPE"? Do I use the database field name or the Field name? Do I have to rename ISSUETYPE to ITEMTYPE? Or just create an "ITEMTYPE" field? Or, should I use the Field Name or the Database Field name? I've tried both ISSUETYPE database name and the  Item Type field name, both failed to trigger the IF logic.

    My issuetype its named ISSUETYPE in my project.

    Here's my new test code:

    The ISSUETYPE is: $FIELDVALUE(ISSUETYPE)

    $IF(ISSUETYPE, Oracle)

       This is an Oracle issuetype.

    $ELSE()

      This is not an Oracle Issue Type.

    $ENDIF()

    *****************************************************************************************************

    Results:

    The ISSUETYPE is: Oracle

    This is not an Oracle ISSUETYPE.

    *****************************************************************************************

  • 0 in reply to 

    Yes, "ITEMTYPE" is the TS_ISSUETYPE aka "Item Type" field.  That particular incantation of the "$IF()" might require "ITEMTYPE". Confusing, huh?

    For the notification tags, copy anything in UPPERCASE as-is in the docs.  Lower case params represent data or field names from the associated table.

    $IF(CANVIEW, fieldname)

    $IF(ITEMTYPE, value or prefix from TS_ISSUETYPE aka "Item Type" field)

    $IF(VIEWLINK)

    I think you might need to move the "Platform is M5 or M8" tests and decision making to M5 and M8 specific Notifications & Notifications Rules, then for each Notifications create a template.  Like an "M5" template and an "M8" template.

  • 0   in reply to 

    I think ITEMTYPE is a misnomer in the documentation. It refers to the app type. The documentation says:

    >Returns information based on the application to which the notification is related.

    >Parameter is either, singular item name or application prefix.

    The example given is "Change Requests" which is one of the sample apps.

    As far as I know, there is no way to use an $IF tag with any field.

  • 0 in reply to 

    Yes, we are doing the separate template solution now. It's a maintenance nightmare. It would be nice if I could have just one template with difference content fed out by if statements. We have over 100 message templates that are essentially the same content with only some content changing based on Item type. So, if we change the content on one we have to change it on over 100. .

  • 0   in reply to 

    I totally understand the nightmare as I've been there before. One thing I have done in the past to try and circumvent this is to use a text memo field within the app to hold extra "template data". This could be done plain-text or HTML. Then I use form-actions or scripting in Composer to set this field based on other field criteria. This can be a partial amount, or the entire template depending on your needs (also note a single memo field in SBM is limited to, including html markup, about 65000 characters).

    For example, my template might look something like:

    $BEGINSUBJECT()Really important notification $TTID() $ENDSUBJECT()
    Attention, 
    Item $TITLE() was edited by $FIELDVALUE(LASTMODIFER) and needs your review.
    
    Here are some details:
    $FIELDVALUE(SPECIAL_TEMPLATE_FIELD)
    
    To view the item click $LINK(swc, here);

    Then, in composer I would set the "SPECIAL_TEMPLATE_FIELD" to whatever was needed. When users edit an item the action/script would ensure this field is correct, and then when notification sends you can get the desired uniqueness. You just need to ensure that all users that could receive notification have access to view the field.

  • 0   in reply to 

    In addition to what  has suggested, I've used the html capabilities of email to show/hide based on a field value. It doesn't work in all scenarios as CSS selectors are specific, but it might help.

    First, I added a style section to the email:

    <style>
    .EmployeeOther, .ContractorAE, .ClientAE, .VisitorAE, .PublicAE {display:none;}
    </style>

    Then added the classes to the particular sections that I wanted to show or hide:

    <span class="$FIELDVALUE(CATEGORY)AE"><b>Employee</b>: $FIELDVALUE(EMPLOYEE_AFFECTED) </span>
    <span class="$FIELDVALUE(CATEGORY)Other"><b>Name</b>: $FIELDVALUE(FIRST_NAME) $FIELDVALUE(LAST_NAME) </span>

    In this case, it shows the first line if category is employee, or it shows the second line for all other categories.

    You could probably do the following too, which would be close to an if statement, though I haven't tested this:

    <style>
    .hideInitial {display:none;}
    .$FIELDVALUE(Platform)show {display: block}
    </style>

    <div class = "hideInitial M3show">Show for M3</div>
    <div class = "hideInitial M8show">Show for M8</div>

    In this case, it hides everything, and then shows the ones based on the platform.

  • 0 in reply to   

    Great idea!