Monthly Archives: April 2009

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 ……….

🙂

Leave a comment

Filed under MS CRM & Javascript

Hide ms crm picklist items

Today i got requirement to hide some picklist option based on customer type selection(in my case 🙂 ) here is how i did this

like we have one picklist for customer option “A” and “B” and we have a picklist crmpicklistfacility with different facilities like

1 “Create new User”

2 “Modify User”

3 “Delete User”

now we want to present picklist option 1,3 for customer A and 2 for customer B.

we do like this in javascript

var Cust_type=crmForm.all.customertype.DataValue;

var crmpickObj=crmForm.all.facility;

if(Cust_type==”1″)

{

crmpickObj.DeleteOption(2);

}

else if(Cust_type==”2″)

{

crmpickObj.DeleteOption(1);

crmpickObj.DeleteOption(3);

}

Leave a comment

Filed under MS CRM & Javascript