Open the appropriate selector page

Posted by IramK on 19-Mar-2015 10:02

Hello,

I have three selector pages in my object and I would like to open one of the newly created selector page when the user clicks on the attach button on the related record's view page. Is there a way I could get the selector Page ID dynamically?

Posted by Godfrey Sorita on 20-Mar-2015 11:41

The token uses the original ID of the page and it returns a link with the pageID on the current zone. The code does not break even if it is installed to another zone or instance.

All Replies

Posted by Godfrey Sorita on 19-Mar-2015 12:55

You can assign pages per user role by going to Administration Setup > Roles > Pages. Though having multiple selector pages, I believe this solution is not what you're looking for.

As a workaround, you can use the code below:

<script>
$(function() {
  //IMPORTANT: Replace {!#LINK.relation#10152} with the token of the selector page
  var origPage = "{!#LINK.relation#10152}"; 
  var pageId = origPage.split("pageId=")[1];  //extract selector page id
  
  //IMPORTANT: Replace Relations with the name of the section which contains the attach link.
  var attachOnclick = $("div[name='Relations']").find("a").first().attr("onclick"); 
  var attachOnclick_arr = attachOnclick.split(",");
  attachOnclick_arr[0] = "return rbf_attachRelated("+ pageId; 
  
  $("div[name='Relations']").find("a").first().attr("onclick", attachOnclick_arr.toString()); //replace onclick function of attach button
});
</script>


Regards,

Godfrey

Posted by IramK on 20-Mar-2015 04:21

Where can I find the token of the selector page? Is that available to us?

Posted by Godfrey Sorita on 20-Mar-2015 10:20

Please follow the steps below to get the token:

1. Go to the related object's definition.
2. Under Pages section, click the Page Name of the selector page.
3. Look for the Template Token field.

Posted by IramK on 20-Mar-2015 10:30

Yes but that's when you know the selector's ID you want which is right what you provided but can I not get like a list of selectors available to me and get the selector ID based on the selector name?

Eg: say I have three selectors: Hello Mark (ID: 10), Hello Martin (ID: 11) and Hello world (ID:12) and I would like to choose Hello World. Is there a way I could get the ID:12 by providing the name of the selector i.e. Hello World?

The only reason we want it to be dynamically populated is because we possibly might migrate our apps to a different server and the ID's might change. Hence we want to make sure that we don't hard code any ID's and use the dynamic ones based on selector names.

Posted by Godfrey Sorita on 20-Mar-2015 11:41

The token uses the original ID of the page and it returns a link with the pageID on the current zone. The code does not break even if it is installed to another zone or instance.

This thread is closed