Adding Hyperlink on Search Select Advanced Field in View Mode

By | March 25, 2013

One fine day one of our client came up with a new requirement. The requirement was to convert a Search Select Advanced field value to a hyperlink for a custom entity. To understand the requirement let us consider a standard entity Case as we all are quite familiar with the same. When we create a case then we can see the Company and Person fields as a Hyperlink in a view mode. Please refer the below screen shot for the same:

This is quite user-friendly as user can directly navigate to that particular Company or Person from the case context without taking much efforts. This is a functionality in Sage CRM for the standard entities only. But now the same can be implemented for a custom entity as well.
We have a custom entity Contract. This Contract entity has a Search Select Advance field Contract Name. This Contract Name field is displayed on the Company Summary screen which needs to be a hyperlink in a view mode. Refer the below screen shot for the same:
Where the Contract Name is a hyperlink which on click navigates to the Contract summary page.
We have written the code which will implement the above for you. All you have to do is just follow the simple steps given below:

  1. Log in to CRM as an Administrator.
  2. Navigate to Administrator| Customization| Company
  3. Click on Screens Tab
  4. Click on the Company Entry Screen. The Below screen will get displayed.
  5. Copy the Code and Paste the below code in the Create Script for the custom entity filed (in our example it is Contract Name):

//‘Create Script in Contract Field Company
var sAct= new String(Values(“Act”));
if(sAct==”” || sAct==”undefined” || sAct==””)sAct=””;
var ContractID = new String(Values(“comp_contract”));
if(ContractID==”” || ContractID==”undefined” || ContractID==””)ContractID=””;
var ContractSummmaryURL = eWare.URL(“ContractNumber/ContractNumberSummary.asp”)
Caption =”Contract : <input type=hidden name=_hidenContractNumber id=_hidenContractNumber value=”+ContractID+”>”
Caption += “<input type=hidden name=_HiddenContractSURL id=_HiddenContractSURL value=”+ContractSummmaryURL+”>”
Caption += “<input type=hidden name=_HiddenAct id=_HiddenAct value=”+sAct+”>”

  1. Copy the Code and Paste the same in the Custom Content for the same entity.

//’In Company Custom content
< script >
jQuery(document).ready(function(){
var sAct = $(‘#_HiddenAct’).val();
var ContractID = $(‘#_hidenContractNumber’).val();
var ContractSummaryURL = $(‘#_HiddenContractSURL’).val();
var ContractHTML = $(‘#_HIDDENcomp_ContractnumberTEXT’).val();
sURL = ContractSummaryURL + “&Contract_ContractNumberID=”+ContractID;
sContractHTML = “<a href=”+sURL+”>”+ContractHTML +”</a>”;
if(sAct==”200″ || sAct==”520″)
$(‘#_Datacomp_Contractnumber’).html(sContractHTML);
});
< /script >
Note: You will have to replace your custom entity field name in the above code.

  1. Click on Update
  2. Click on Save.

If you click on the Change button on the Company Summary screen, the screen will be displayed in an edit mode. The Contract Name Search Select Advance field will also be displayed in an edit mode. Our above code will allow you to navigate to the particular contract summary when the link is clicked even in the edit mode as well. This is also a standard functionality for the Standard Search Select Advance fields in Sage CRM.
The above code will just work like a standard Search Select Advanced hyper-linked Field in Sage CRM.