• Derek Wiers (W)
  • NEWBIE
  • 10 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 2
    Replies

Hi,

 

I originally created a custom button on the Contact page layout that allowed me to start a flow. The code that worked fine is as follows:

 

/flow/Enable_SLink_Access
&varContactId={!Contact.Id}
&retURL=/{!Contact.Id}

 This worked great. However I now need to add some JavaScript to this button to analyse the current users profile to allow or deny running the flow.

 

The new code now looks like this:

 

//Required by Salesforce.com to run OnClick JavaScript
{!RequireScript("/soap/ajax/10.0/connection.js")}

if ( '{!User.Profile}' != 'System Administrator' )
{
alert('You are not authorised to edit SLink Settings for this Contact');
}
else
{
window.open('/flow/Enable_SLink_Access&varContactId={!Contact.Id}&retURL=/{!Contact.Id}');
}

 However now it takes me to an invalid URL where the message on screen says 'URL No Longer Exists'.

 

The URL has become: https://cs2.salesforce.com/flow/Enable_SLink_Access&varContactId=003R000000Z7dEv&retURL=/003R000000Z7dEv

 

Can anyone help me with the code I should dress up the flow bit of the code with please?

 

Thanks very much,

 

Marco

Hey,

An interesting little quirk related to case insensitivity in Apex.  If you go

String s1 = 'a';
String s2 = 'A';
system.debug ( s1 == s2 );


...it'll say 'true' as you'd expect.

But now do this:

Set<String> s = new Set<String> { 'a' , 'b' };
System.debug ( s.contains ( 'a' ) );
System.debug ( s.contains ( 'B' ) )
;

...the second debug statement says 'False'; in other words, you cannot find that second set element by 'B'.

Thus - this little corner of Apex is case-sensitive.   The same thing applies to Map keys, which makes sense, as they're probably implemented similarly under the sheets.

This can be used to your advantage if you need to do a case-sensitive compare between strings:

static boolean streq ( String a , String b ) {
    Set<String> s = new Set<String> { a };
    return ( s.contains ( b ) );
}


-philbo

  • October 16, 2008
  • Like
  • 0