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.
     window.open( 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";
        Xrm.Page.getAttribute("regardingobjectid").setValue(partlistData);

    }

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.
    window.open("/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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s