Customer Portal

Get Involved. Join the Conversation.

Topic

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

    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.

    Version:
    Service Cloud Nov' 14, CP2

    Comment

    • Anuj Behl

      What is your CP framework version? You can check it on CP admin portal or from this link: http://<site-url>/ci/about

      UPDATE: Sorry, didn't see that you had already mentioned CP2 in your post.

    • Matthew Callison

      It's CP2, version Nov 2014

    • Anuj Behl

      Can't see any issue with your code. I had it work fine with both CP2 and CP3 earlier.

      Can you try the messagebase ID once instead of messagebase key in the function like

      alert(RightNow.Interface.getMessage(14387));

      -Anuj

    • Barrilito van Dijk

      Hi Matthew,

      There have been lots of replies trying to help out, but still no success. I think there are just a few steps left for you:

      • Try Anuj's tip to put in an existing ID instead of a message name
      • Perhaps try it without any qoutes!
      • Try my suggestion to use the yml file, or do a fetch via the controller ( RNCPHP\MessageBase::fetch(ACCESSKEY_LBL) ) just to make sure it is possible to pull out ANY message at all !
      • Make sure the message you are pulling out contains something, have you checked the content of the message in the console? Isn't it empty?
      • If you have checked all the above and everyone seems to believe it should work, raise a servicerequest @ Oracle.

      Hope this helps out. Regards!

       

    • Pramod Vasudeva Murthy

      Hi Matthew,

      I had a similar issue like this before; I had a work-around for this.

      Since you are creating a Custom widget, In controller you can get the Message base like this:

      $global_template_msg_base = RNCPHP\MessageBase::fetch(<msg_base_id>);
      $global_template = $global_template_msg_base->Value;

      Store this in one of the in-built attributes:

      $this->data['attrs']['msg_base_value'] = $global_template;

      OR

      $this->data['js']['msg_base_value'] = $global_template;

      You can access the same in logic.js as:

      var msg_base_value = this.data.attrs.msg_base_value;

      OR

      var msg_base_value = this.data.js.msg_base_value;

      Hope this helps..

      - VIP

    • Dietrik

      Obviously, if this would not work, lots of messages would  not process correctly.

      I'd check the paths in the view.php or start with a simple nearly empty custom widget. 

    • Barrilito van Dijk

      Hi Matthew,

      Do you have an update on this, did you try some things?

      Regards.

    • Matthew Callison

      In the short term I came up with a work-around in the controller file.  It's cludgy, but it's working.

      I've opened a Service Request to have this looked at.  It appears that this may not be working in some standard widgets, either, so we have a problem.

      Thanks for everyone's help.

    • Barrilito van Dijk

      Hi Matthew,

      Thanks for the update. Yes, its probably something site related as it should be working, so indeed let Oracle take a look at it.

      Perhaps you can share the workaround if it differs from the suggestions in this post.

      Regards.