Customer Portal

Get Involved. Join the Conversation.


    Matthew Callison
    Accessing MessageBase from logic.js
    Topic posted June 6, 2016 by Matthew CallisonBlue Ribbon: 750+ Points 
    447 Views, 24 Comments
    Accessing MessageBase from logic.js

    I am trying to pull in the value of a MessageBase in the logic.js file of a custom widget.  I have opened up some standard widgets, and the format they use is something like:

    keyComboString = RightNow.Interface.getMessage("ACCESSKEY_LBL");

    However, when I use that, nothing comes through.  I've put markers before and after the spot I want the text, so I know I am in the correct area.

    Service Cloud Nov' 14, CP2


    • JustRhianna

      Can you include an actual code snippet?

    • Barrilito van Dijk

      Hi Matthew,

      I think that way of working is perhaps limited to standard widgets.

      When using a custom widget, you should set labels using the info.yml file.

      Like this:

              name: rn:msg:HEADER_LABEL_LBL
              type: string
              description: rn:msg:LABEL_TO_DISPLAY_ABOVE_FORM_LBL
              default: rn:msg:WAS_THIS_ANSWER_HELPFUL_MSG

      Here the label_title has been set with WAS_THIS_ANSWER_HELPFUL_MSG as the default label. In the logic you can call it with:

      Hope this makes sense. Off course there are many other ways to get what you want...


    • Anuj Behl

      Hi Matthew,

      You can certainly use the getMessage method to get value of standard and custom message bases. As suggested by Rhianna, it would help if you could post the actual code snippet where you having trouble.


    • Matthew Callison

      The line I listed above is the actual code snippet that I pulled from a standard widget:

      keyComboString = RightNow.Interface.getMessage("ACCESSKEY_LBL");

      I've tried using that in my extended widget, and it does not work.  Another line I am trying is:

      saDisplay += "<div class='rn_Response'>x" + RightNow.Interface.getMessage("ALT_LBL") + "</div>";

      ...and the "x" that I put in front shows up, but not the MessageBase text.

    • Anuj Behl

      Hi Matthew,

      Try single quotes for the messagebase label instead of double quotes as below:

      saDisplay += "<div class='rn_Response'>x" + RightNow.Interface.getMessage('ALT_LBL') + "</div>";

      Let us know if it works.

    • Matthew Callison

      Using single quotes does not work, unfortunately.

    • Anuj Behl

      Do you get any error while debugging? You can check with firefox's firebug console or chrome devtools console section.

    • Matthew Callison

      No errors, and inspecting the element looks normal, the text just isn't there.

      This is for the SmartAssistantDialog widget, if that makes a difference.  All the changes I've made in extending the widget are working great, with the exception of being able to pull in a MessageBase.

    • Anuj Behl

      Sorry, I meant when the page loads, do you see any errors in console?

      After the page finishes loading, open page source and search for 'setMessagebase'. RightNow pre-loads all the messagebase values used in javascript files on page load and stores in this method. Check if you see your messagebase key in the function body.

    • Matthew Callison

      I knew what you meant by errors in the console, and there are none.

      I checked the "setMessageBase" area (that's new information to me, so thank you), and that MessageBase is not in the list, so for some reason it is not being loaded.  Is there anything that needs to be enabled for this to work?

    • Anuj Behl

      That's strange.

      Let's see, did you try accessing a custom message base with this syntax instead of a standard one? Do you have any other custom widget on page where this is working?

    • Matthew Callison

      The purpose behind this is to use a custom message base, yes.  When that didn't work, I tried using a standard one to see if it would work.

      This is the first widget I have tried using this on.  I originally thought I would have to pull them in the controller or the view, but when I saw it in the logic.js file, it seemed like it would save a lot of time because it needs to go right with all the other stuff that is being accessed for the Smart Assistant.  "RightNow.Interface.getMessage()" should work, right?

    • Anuj Behl

      Yes, I have used the same multiple times.

      Could you tell me how did you create this custom widget? If possible, can you try with this line just after you call parent constructor in widget's constructor function.


    • Anuj Behl

      Sorry, missed adding alert in the line. Corrected code below:



    • Matthew Callison

      Nothing showed up, and that entry was not in 'setMessageBase'.

      I started by copying the standard widget to a folder in the custom widgets directory of the same name, i.e. /custom/input/SmartAssistantDialog.  Then I updated the controller_path, js_path, and base_css in the view.php to point to the new folder.