1

I am facing an issue with a custom onclick-javascript button that is used in the Partner Portal, Console and in "regular" Salesforce. I have the following RequiredScripts in the button:

{!REQUIRESCRIPT("/soap/ajax/33.0/connection.js")}
{!REQUIRESCRIPT("/support/console/33.0/integration.js")}

This is working fine in the console and in regular console, but in the Partner Portal I get the following issue in my developer console (only when clicking the button the first time, clicking it again right after works fine): Error

I can see that if I manually try to access the url "https://XXXXXXX.cs18.force.com/partners/support/console/33.0/integration.js" I can see the script file, I have tried to in my Requirescript change the following: {!REQUIRESCRIPT("partners/support/console/33.0/integration.js")} but that does not work neither, and I assume that would not work in the console anyway.

I could of course create two seperate buttons, one for the Partner Portal that does not have the {!REQUIRESCRIPT("/support/console/33.0/integration.js")} at all. This is however my last resort, since it would mean that I would end up with two buttons on the Page Layout and this may confuse and irritate the users (even if they have different names).

This would be easy to fix if Salesforce would have a way of customizing the visibility and access of custom buttons based on permission sets, profiles, roles or whatever, but for now I am in the dark here.

Does anyone have any suggestions regarding this?

Ciao!

2
  • couldn't you do {!REQUIRESCRIPT(IF($User.UserType='PowerPartner',NULL,'/support/console/...')} ? or some variation of this? See doc on UserType in the SFDC Objects Guide – cropredy Mar 6 '16 at 7:41
  • thanks @crop1645, the following seems to work fine: {!REQUIRESCRIPT(IF( ISPICKVAL( $User.UserType , 'PowerPartner') ,NULL,"/support/console/33.0/integration.js"))}. I did not know that this could be done directly i nthe Requirescript, or rather that you could provide NULL there. Thanks for this. If you add your comment as an answer with the correct syntax I will mark that as correct. – erikduvet Mar 7 '16 at 12:21
1

REQUIRESCRIPT is like any other SFDC function in that its arguments can be manipulated with other functions. All you need to know is when you are in the Partner Portal context.

One way of knowing you are in the Partner Portal context is based on the running user, the properties of which are available through the global variable $User.

To see what properties are available, go to the Sobject in question, the custom button in question, and then choose $User as the 'Field Type' and then examine the dropdown in 'Insert Field'. $User.UserType` is the one to use.

enter image description here

$User.UserType possible values are documented in the [SFDC Object Reference] and specifically PowerPartner is used for Partner Portal users.2

Alternatively, you could also use $UserRole.PortalType - which, when has a value of Partner, indicates user has a Partner Portal Role.

Putting this altogether, your custom button line becomes

{!REQUIRESCRIPT(IF(ISPICKVAL($User.UserType ,'PowerPartner') ,NULL,"/support/console/33.0/integration.js"))}

or

{!REQUIRESCRIPT(IF(ISPICKVAL($UserRole.PortalType ,'Partner') ,NULL,"/support/console/33.0/integration.js"))}

I imagine you could also do:

{!IF(ISPICKVAL($User.UserType,'PowerPartner'),
     NULL,
     REQUIRESCRIPT('/support/console/33.0/integration.js')
    )}

if you like that style of coding. REQUIRESCRIPT essentially returns a string of script..</script> so it is suitable to be the true/gfalse result of an IF expression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.