Screen Customisation

From Sage CRM Knowledge Base

To add in script code from a page set the link as follows

 <script src="../custompages/pathtofile/commlist.js" type="text/javascript" language="JavaScript"></script>

To enumerate block entries (Ref: https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2007/11/28/setting-screen-properties-within-a-multiblock-asp-page-using-the-com-api.aspx)

 //Set EntryBlock properties for an EntryGroup Block using an Enumerator
 var myE = new Enumerator(myBlock);
 while (!myE.atEnd())
 {
    myEntryBlock = myE.item();
    myEntryBlock.ReadOnly = false;
    myEntryBlock.Required = false;
    myE.moveNext();
 }



Useful menthod to parse the querystring from the client

Ref: http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx

 function getQuerystring(key, default_)
 {
   if (default_==null) default_="";
   key = key.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
   var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
   var qs = regex.exec(window.location.href);
   if(qs == null)
     return default_;
   else
     return qs[1];
 }



To break up a screen visually create a dummy field and add in

 <HR border=1>

as the caption


Adding new phone and email addresses to screens

Go into translations and look up Link_CompPhon (or link_prefixphone/email)

This shows you a list which you can add to by adding new translations



Custom validation on a screen

If you have a custom method for validating data and you wish to code this in your ASP page (or outside of the validation script area) then you need to do something like the following

 Entry = ctproductblock.GetEntry("productname");
 if(!validate(Request.Form("productcode")))
 {					
     Entry.ValidateScript = "Valid=false;ErrorStr='Product code already exists';"; 
 }

if our sample above the validate() method checks that the product code is unique.

Ref: https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2007/07/22/server-side-validation-and-asp-pages.aspx



Add a hyper link to a field on a screen - Custom SSA fields can only be hyperlinked throught the UI for lists and not for screens so here we have a workaround.

Ref: https://community.sagecrm.com/partner_community/b/hints_tips_and_tricks/archive/2010/07/06/hyperlinking-to-a-parent-custom-entity-from-a-search-select-advanced-field.aspx

  • Within CRM open the screen
  • Select the field
  • Within the "create script" textbox enter in the following (update as per your custom entity first)
 var intRecordId = CRM.GetContextInfo("opportunity","oppo_projectid");
 var strURL = CRM.URL("project/projectsummary.asp")+"&proj_projectid="+intRecordId;
 var strCaptionText = "Project";
 var strFullCaption = "<a href="+strURL+">"+strCaptionText+"</a>:";
 Caption = strFullCaption;

This sets the field "Caption" to be a hyperlink so it is not ideal but works as a quick "fix"



Field Validate scripts - Values vs values - (seen in 7.1)

This threw me a few times....within field validate scripts the "values" object starts with a lowercase v

 ErrorStr="testx="+values("case_ct_supportemail");

Anything in values only comes from the screen so if the field referenced is not on the screen then it wont be in values - you would then query the db to get that value.



Ajax Request

function _makeRequestGET(path, callback) {

 _dbg("_makeRequestGET path:"+path);
 
   $.ajax({
       type: "Get",
       url: path,
       success: function (data, text) {
           callback(data);
       },
       error: function (request, status, error) {
           alert("ERROR in _makeRequestGET: "+request + " status:"+ status + " path:"+ path);
       }
   });

}