Monday, June 1, 2015

MSCRM 2011 LOOKUP Multi Value Selection

/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");

 }

No comments:

Post a Comment

How to Deploy your API as a web app or API app

  Before you can call your custom API from a logic app workflow, deploy your API as a web app or API app to Azure App Service. To make your ...