Skip to main content
Nintex Community Menu Bar
Question

How do I access salesforce custom labels in a snippet? I tried $A.get($Label.Name_Of_Label") but it"

  • July 9, 2024
  • 6 replies
  • 70 views

Forum|alt.badge.img+2

Access Custom Label

This topic has been closed for replies.

6 replies

Forum|alt.badge.img+9

“$A” is the shorthand for Aura in lightning components, I don’t think that will work with skuid, I think you want something like this:

skuid.utils.mergeAsText("global","{{$Label.Name_Of_Label}}")


That should work according to these links:

http://help.skuidify.com/m/11720/l/187263-global-merge-variables-functions

http://help.skuidify.com/m/11720/l/129517-skuid-utils


Forum|alt.badge.img+2

Hi Moshe,

I tried these approaches but they doesnt seem to be working. I am looking to use the labels in javascript. 

I tried something like this but no luck. 

var testLabel = {$Label.LABEL_NAME};
console.log(testLabel);


Any other ideas?

KR.


Forum|alt.badge.img+4

Hi Kalyan,

Moche’s approach works for me. 

You will need to add the Custom Label to the Skuid page first before it can be accessed by this method or in a merge template, otherwise that method will just return an empty string. 

Ryan


Forum|alt.badge.img+2

Hi Ryan,

I am trying to access a label as shown below:

var specialSegment = skuid.utils.mergeAsText(“global”,“{{$Label.Special_Partner}}”);

but have got an error saying :
skuid__SkuidJS:26 Uncaught TypeError: Cannot read property ‘organizationId’ of undefined

Any idea on how to utilize this method from utils ?


Forum|alt.badge.img+4

Hi Kvin,

That code looks okay. 

Are you sure your error isn’t being thrown by a different line of code? Look for a line that attempts to access a field called organizationId on an object. 

Have you tried debugging using console.log or alert statements?


Forum|alt.badge.img+2

Hi Ryan,

Thanks for taking time to respond on this.
I got this working.

The reason was : The Skuid.utils.userInfo object is only available once the page is loaded.

So if you intend to access this in “inline” snippet
$(document.body).one(‘pageload’,function(){

//Here you should be able to access as shown below
 var specialSegment = skuid.utils.mergeAsText(“global”,“{{$Label.Special_Partner}}”);    console.log(‘specialSegment from Label’,specialSegment);

});