Thursday 12 April 2012

MSCRM 2011 LOOKUP Multi Value Selection




MSCRM 2011 LOOKUP Multi Value  

Hi This is Sudhakar Reddy Chidipudi

By default you can select only one value from lookup.I thought to post the below code ,by using below code you can select multiple values from lookup.

Below you can see i wrote two functions ,OnSave of the form you can get the multiple values from lookup and save those values in a multiline text box.

To use the below code you need a lookup and one multiline text box.

//Form Onload
function  load()

{

document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "multi");

document.getElementById("Your lookup Schema Name").setAttribute("_lookupstyle", "multi");
if(Xrm.Page.ui.getFormType()!=1)

{
var data=new Array();
// I created a one multiline text box to save the lookup values.
// set the multiline textbox visible equal to false.

var store=Xrm.Page.getAttribute("new_textbox").getValue();

data=store.split(";");

// To get the "Target record type" Go to your form Customization ---> double click on your lookup--->Details--->Edit--->Here you can see "Target Record Type"

var typename = "Target Record Type";

 var arr= new Array();
 var  i=0;
var   j=0;

for(i=0;i<((data.length-1)/2);i++)

{

arr[i] = new Object();

arr[i].name = data[j];

arr[i].id= data[j+1];

arr[i].typename= typename ;

j++;
j=j+1;

}

crmForm.all["Your lookup Schema Name"].DataValue = arr;

}

}
//Form OnSave

function save()

{


 var value = crmForm.all["Your lookup Schema Name"].DataValue;
var s;
var temp="";

for (s=0;s<value.length;s++)

{

var temp2="";

temp2=value[s].name+";"+value[s].id+";";
temp=temp+""+temp2;

}

Xrm.Page.getAttribute("new_textbox").setValue(temp);

Xrm.Page.getAttribute("Your lookup Schema Name").setValue(null);

document.getElementById("Your lookup Schema Name").setAttribute("lookupstyle", "single");

 }


Have a nice day.................................
Sudhakar Reddy Chidipudi


Thursday 5 April 2012

Sending Email From Office 365 Online


Hi 


It is easy to send email from office 365 online .Below is the code .

  SmtpClient server = new SmtpClient("Your email server name");         
                server.Port = 587;
                 server.EnableSsl = true;
                server.Credentials = new System.Net.NetworkCredential("Your outlook login id", "Your outlook login password");
                server.UseDefaultCredentials = false;
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("From mail address");
                mail.To.Add("To address");
                mail.Subject = "Your Subject";
                mail.Body = body;
                mail.IsBodyHtml = true;
                server.Send(mail);



Enjoy........................