MSCRM 2015, 2016 Business Process Flow Stage Change Automatically Using JavaScript

Hi this is Sudhakar Reddy Chidipudi

In real time scenarios BPF should be moved from one stage to another stage automatically .

Below JavaScript does the same.

function moveNextStage(stgName, flowStatus)

{

try

{

var pollingAttemptsRemaining = 10;

var intervalId;

intervalId = setInterval(function ()

{

pollingAttemptsRemaining -= 1;

if (Xrm.Page.data.process.getActiveStage().getName() != stgName)

{

clearInterval(intervalId);

}

if (!Xrm.Page.data.entity.getIsDirty() && Xrm.Page.data.process.getActiveStage().getName() == stgName)

{

if (flowStatus)

{

Xrm.Page.data.process.moveNext(moveResult);

}

else

{

Xrm.Page.data.process.movePrevious(moveResult);

}

pollingAttemptsRemaining = 0;

clearInterval(intervalId);

}

if (pollingAttemptsRemaining <= 0)

{

clearInterval(intervalId);

}

}, 200);

}

catch (err)

{

Xrm.Page.ui.setFormNotification(“Error occured in function : moveNextStage()” + “.Details : ” + (e.description || e.message), “ERROR”);

}

}

function moveResult(result)

{}

How to call above function? Use below code

moveNextStage(“Your BPF stage name”, true); //true moves stage forward  .

Have a nice day …………………………. 🙂

MSCRM 2013 LOOKUP Multi Value Selection

Hi This is Sudhakar Reddy Chidipudi

In my previous post(http://mscrm2011kt.blogspot.in/2012/04/mscrm-2011-lookup-multi-value-selection.html) i have written javascript to select multiple vales from lookup ,but that script does not work for MSCRM 2013.

If you do simple changes to my script ,it works as expected for mscrm 2013.

document.getElementById(“Your lookup Schema Name”+”_i”).setAttribute(“lookupstyle”, “multi”);

and you have to add event hadler to the lookup,in event hander you have to set lookup as multiselect.

I hope this gives an idea.

Have a nice day……………………………
Sudhakar Reddy Chidipudi

Load Json,JQuery from Home page of MSCRM 2011

Hi All,

This is Sudhakarreddy Chidipudi

Now i will explain how to load Json,Jquery scripts from homepage grid of CRM Entity

Every ribbon button has CommandDefinition .We can load the script files from this CommandDefinition of actions tags.

Below is the example of load the script files form home page grid.

<CommandDefinition Id=”Mscrm.HomepageGrid.SudhakarReddyLoadScripts”>
<EnableRules>
</EnableRules>
<DisplayRules>
</DisplayRules>
<Actions>
<JavaScriptFunction FunctionName=”$” Library=”$webresource:new_jSon” />
<JavaScriptFunction FunctionName=”$” Library=”$webresource:new_jQuery” />
<JavaScriptFunction FunctionName=”MyTest” Library=”$webresource:sudhakar_Functions”>
</JavaScriptFunction>
</Actions>
</CommandDefinition>

Default form data values using QueryString arguments

Hi All

Sometimes you may have to open a new crm from using QueryString arguments with default values

We can achieve by using extraq parameter in url

1)Set the default Value for Lookup

To open a new record with default values then below sysntax you can use,

Below is the example of opening primary contact of account ,

I have a contact with the name of “Sudhakar Reddy Chidipudi”.I want to open the account form with the default contact is “Sudhakar Reddy Chidipudi”.

https://anjali.crm.dynamics.com/main.aspx?etc=1&pagetype=entityrecord&extraqs=primarycontactid%3D{Here you have to provide your record id}%26primarycontactidname%3D Name of your record.

%3D Represents equal(=) and %26 represents &.

2)To open the new record with default name

https://anjali.crm.dynamics.com/main.aspx?etc=1&extraqs=name%3DSudhakarReddyChidipudi&pagetype=entityrecord

Have a nice day 🙂

Exception handling in MSCRM 2011 Online

Hi this is  Sudhakar Reddy Chidipudi

Today i am going to explain the ways of handling exceptions in MSCRM 2011 Online.

Bit difficult storing exceptions in MSCRM 2011 online.Reason is sandbox plugins are partial trust.

Sandbox plugins have retriction on file system.

Below are the different ways

1) Crearte webservice or WCF service to log your error.

2)Create custom entity and create record for each error.

I will explain in detail soon with example ……………….. 🙂

Sudhakar Reddy Chidipudi

Found more than one ribbon diff enitity in MSCRM 2011

Hi This is Sudhakar Reddy Chidipudi

Some times when you import customization’s you get a error “Found more than one ribbon diff enitity“.

It means if any id is duplicated in <RibbonDiff/> it throws error.

Funny thing is when you import your customizations first time to the new organization it does not throw any error .

If you do some customizaton later and then try to import to your organization it throws the above error.

To resolve the above error first import empty <RibbonDiff/> and then publish customization of enitty and then import your original customizations.
Have a nice day …………………………. 🙂

 

MSCRM 2011 UnResolved Emails

Hi This is Sudhakar Reddy Chidipudi  

What is unresolved email?

If any mail does not exist in MSCRM organization then we call it as UnResolved email.

Some times when you try to send a email it shows error regarding unresoved emails.

To resoved that navigate to

Administrator–>SystemSettings–>EmailTab,

Select the radio button to yes “Allow messages with unresolved e-mail recipients to be sent”

 

Do you want to load unresolved emails using javascript?

var obj = new Object();
obj.name = “EmailAddress”;
obj.category = 3;
obj.type = 9206;

Simple………..:)

MSCRM 2011 LOOKUP Multi Value

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(“primarycontactid”).setAttribute(“lookupstyle”, “multi”);
document.getElementById(“primarycontactid”).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

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”);

// To get  “Your email server name”  go to account setting there you can see outgoing   //SMTP mail server
server.Port = 587;
server.EnableSsl = true;
server.Credentials = new System.Net.NetworkCredential(“Your  login id”, “Your 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);