Open new window on some event


i was just trying to open new service activity window on some event  & and after that i was trying to set customers according to the parent contact id

i was just trying with

window.open(‘/activities/serviceappointment/edit.aspx’);

and i write following code to access paraent contactid look on form load event of service activity window.

// to create lookup array

var customer_lookup=new Array();

// to check for new form

if (crmForm.FormType == 1)
{
 // Check to confirm that the window.opener is present.
 if (window.opener)
 {
  // Get the values of the parent form.
  var oParentCrmForm = window.opener.document.all.crmForm;
//To check Window.opner is calim entity or not

//10000 objectTypecode for my custom entity you can query ur organization database to check your custom entity’s objectTypecode

if (oParentCrmForm && oParentCrmForm.ObjectTypeCode == 10000)
{
var customer_lookupItem= new Object();
customer_lookupItem.id=oParentCrmForm.all.asu_contactid.DataValue[0].id;
customer_lookupItem.typename=’Contact’;
customer_lookupItem.name=oParentCrmForm.all.asu_contactid.DataValue[0].name;
customer_lookup[0]=customer_lookupItem;
crmForm.all.customers.DataValue=customer_lookup;
}

}
}

but i got one confusion when i was trying to open new service activity from action menu i was getting the customers name but when i was trying to open new service activity through my custom button it was not populating …..

after some time i compare both the url Oppsssss i was missing organization name as i was working on multiorganization …….

so i changed my URL fo

window.open(‘/’+ORG_UNIQUE_NAME+‘/activities/serviceappointment/edit.aspx’);

and finally it was working ……….

🙂

Advertisements

Leave a comment

Filed under MS CRM & Javascript

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