Monthly Archives: February 2014

Autopopulate Activity Party Using Query String

In the target form properties we have set up 2 parameters . Every Parameter needs to have a _ in its name.

  • lema_ciname — Type string
  • lema_ciguid — Type uniqid

Then we can call that form from any external application with :

// Type can be CI Action 919780000 && CI Intruction 919780001
function OpenTaskCreation(CIGuid, CIName,Type) {

    var features = "location=no,menubar=no,status=no,toolbar=no,resizable=yes";

    //Encode Guid of regardingObject to set -- lema_ciname , lema_ciguid
    var extraqs = "lema_ciname=" + CIName;
    extraqs += "&lema_ciguid=" + CIGuid;
    extraqs += "&epa_tasktype=" + Type;

    var features = "location=no,menubar=no,status=no,toolbar=no";

    var serverurl = "http://serverrurl/org";
     // Open the window. serverurl + "/main.aspx?etn=task&pagetype=entityrecord&extraqs=" +
     encodeURIComponent(extraqs), "_blank", features, false);


Then, in the form that we are calling we register a js function on the onload event.

function OnSiteVisitTaskLoad() {
    var urlParams = Xrm.Page.context.getQueryStringParameters();
    var ciname = urlParams['lema_ciname'];
    var ciguid = urlParams['lema_ciguid'];

    var partlistData = new Array();
        partlistData[0] = new Object();
        partlistData[0].id = ciguid;
        partlistData[0].name = ciname;
        partlistData[0].entityType = "epa_complianceinvestigation";


This is creation of parameters is only needed to autopopulate Activity parties. For other fields we could use something like.

function OpenNCCreation(LicenceGuid, LicenceName) {

    //Set the values of epa_licenceid field.
    var extraqs = "epa_licenceid={" + LicenceGuid + "}";
    extraqs += "&epa_licenceidname=" + LicenceName;

    var features = "location=no,menubar=no,status=no,toolbar=no";
    // Open the window."/main.aspx?etn=epa_noncompliance&pagetype=entityrecord&extraqs=" +
     encodeURIComponent(extraqs), "_blank", features, false);


More info about Prepopulating creation forms here or in this Microsoft post.


SQL Command for Process control and error fixing

sp_who2 will show all the existing processes with statuses and in the Blkby column we will see if is bloking any other process or if is waiting ofr any process to finish.

sp_who will give info about more processes.

Kill “Process PID” will kill any process. Make sure you run this command on the correct DB.

CRM 2011 Javascript – working with Option sets

If we want to write the value of an option set in a text field.

function onyearchange() {
    var myOptionSet ="lema_year");
    var optionSetText = myOptionSet.getText();

If we need to set the value of an option set based on a text


function SetOptionSetValueByText(optionsetAttribute, optionText)  
  var options = Xrm.Page.getAttribute(optionsetAttribute).getOptions();  
  for(i = 0; i < options.length; i++)  
  if (options[i].text == optionText)