Understanding TargetRelatedLeadToAccount class in CRM


Hi,

I saw one question in Microsoft CRM Development forum, it was regarding the TargetRelatedLeadToAccount class. The user was using this class to update the originatinglead attribute in the account record.

This is how we would be using that class

CrmService service = new CrmService();
service.Credentials = System.Net.CredentialCache.DefaultCredentials;
service.CrmAuthenticationTokenValue = new CrmAuthenticationToken();
service.CrmAuthenticationTokenValue.AuthenticationType = 0;
service.CrmAuthenticationTokenValue.OrganizationName = “orgName”;

TargetRelatedLeadToAccount targetRlTA = new TargetRelatedLeadToAccount();
targetRlTA.AccountId = new Guid(“accountGuid”);
targetRlTA.LeadId = new Guid(“leadGuid”);

SetRelatedRequest srelReq = new SetRelatedRequest();
srelReq.Target = targetRlTA;
SetRelatedResponse srelRes = (SetRelatedResponse)service.Execute(srelReq);

However as it turned out, this class associates an account record to a particular lead record. It doesn’t update the originatinglead attribute in the account record.

We can find a N:N relationships defined between lead and account named “accountleads_association”. Every time we use the above message a particular account record gets associated to the lead.

We can check for it in the following filtered view “FilteredAccountLeads”.

Bye..

Accessing CrmService live or online


This are some of the best articles for this

http://msdn.microsoft.com/en-us/library/bb955360.aspx

http://msdn.microsoft.com/en-us/library/dd548517.aspx

http://blogs.msdn.com/crm/archive/2008/03/10/accessing-crm-live-web-services.aspx

http://blog.philiprichardson.org/2007/12/17/part-3-applications-which-connect-to-crm/

The important thing to remember is that here we need to use the organization’s unique name.

For example the friendly name here is Bliss

the unique name is org582c8 which could be found at

settings—>customization—> Download web service description files.

We need to make use of idcrlwrapper.dll and msidcrl40.dll which needs to placed in our project’s bin\debug folder.

To get  idcrlwrapper.dll we need to do the following

http://msdn.microsoft.com/en-us/library/bb955358.aspx

And lastly we need to add a cs file named windowsliveidticketacquirer.cs in our project. It could be found at the following location

SDK\server\helpers\cs\CrmOnlineAuth.

// Login information For authentication through the Windows Live service.
Static Private String _username = "username@hotmail.com";
Static Private String _password = "password";
Static Private String _partner = "crm.dynamics.com";
Static Private String _environment = "Production";
// Set the name And TCP port Of the server hosting Microsoft Dynamics CRM Live.
Static Private String _hostname = "dev.crm.dynamics.com";
//Set the friendly name Of the target organization.
Static Private String _orgFriendlyName = "Bliss";
// Define an expired authentication ticket Error code.
Static Private String EXPIRED_AUTH_TICKET = "8004A101";
//Passport ticket required To recover from a CrmTicket time out.
Static Private String _passportTicket;
//Attempt a service Call a maximum number Of times before failing.
Static Private int MAX_RETRIES = 5;
Private void Form1_Load(Object sender, EventArgs e)
{
// Step 1,2: Retrieve a policy from the Discovery Web service.
CrmDiscoveryService discoveryService = New CrmDiscoveryService();
discoveryService.Url = String.Format(
"https://{0}/MSCRMServices/2007/{1}/CrmDiscoveryService.asmx",
_hostname, "Passport");
RetrievePolicyRequest policyRequest = New RetrievePolicyRequest();
RetrievePolicyResponse policyResponse =
(RetrievePolicyResponse)discoveryService.Execute(policyRequest);
// Retrieve a Passport ticket from the Windows Live service.
LogonManager lm = New LogonManager();
_passportTicket = lm.Logon(_username, _password, _partner, policyResponse.Policy,
_environment);
// Dispose Of the LogonManager Object To avoid a FileNotOpen exception.
lm.Dispose();

String orgUniqueName = "org582c8"

// Retrieve the CrmTicket.
RetrieveCrmTicketRequest crmTicketRequest = New RetrieveCrmTicketRequest();
crmTicketRequest.OrganizationName = orgUniqueName;
crmTicketRequest.PassportTicket = _passportTicket;
RetrieveCrmTicketResponse crmTicketResponse =(RetrieveCrmTicketResponse)discoveryService.Execute(crmTicketRequest);

//Create And configure an instance Of the CrmService Web service.
CrmAuthenticationToken token = New CrmAuthenticationToken();
// For CRM live Set authentication type To 1
token.AuthenticationType = AuthenticationType.Passport;
// We will need CRM Ticket To Get authenticated
token.CrmTicket = crmTicketResponse.CrmTicket;
token.OrganizationName = crmTicketResponse.OrganizationDetail.OrganizationName;

CrmService crmService = New CrmService();
crmService.Url = crmTicketResponse.OrganizationDetail.CrmServiceUrl;
crmService.CrmAuthenticationTokenValue = token;
// Invoke the desired CrmService Web service methods.
lead myLead = New lead();
myLead.lastname = "Rana";
myLead.firstname = "Nishant";
crmService.Create(myLead);

 

 

Bye..

Getting the error messages for custom workflow activity.


Normally if there are any errors in our custom workflow activity for a given workflow instance, its status reason would be set as “waiting” and we would see the following message

"An error has occurred. Try this action again. If the problem continues, check the Microsoft Dynamics CRM Community for solutions or contact your organization’s Microsoft Dynamics CRM Administrator. Finally, you can contact Microsoft Support."

Obviously the above message doesn’t help us much.

So to find the exact reason for the error, we can do the following,

  • Go to Advanced Find View
  • Click on New
  • Select “System Jobs” for look for drop down.
  • Set condition as
  • Status equals Suspended
  • SystemJobType equals Workflow

And also click on “edit columns”, and using “add columns” add Message (Display Name) column.

wfe1

And the results of the advanced find view.

wfe2

Here we can also do this one more thing,

We can customize the system job (asyncoperation) entity’s form to include the message field in it.

However this cannot be done in supported manner. To enable system job entity for customization we need to run the following query against our Org_MSCRM database.

update entity
set iscustomizable=’1′
where name=’Asyncoperation’

And then customize the “System Job” entity’s form to include the Message attribute in it.

This is how it would look like !

wfe3

 

Bye…

Enabling plug-in for Change Business Unit and Change Manager for systemuser entity.


Hi,

Normally we can’t attach plugin when we change business unit or the manager for a system user.

However we can do this in an unsupported manner,

The message for Change Business Unit is ‘setbusiness’.

Open your OrgName_MSCRM database and run the following query.

update sdkmessagefilterbase
set isCustomProcessingStepAllowed=1
where 
sdkmessageid=(select sdkmessageid from sdkmessagebase where name=’setbusiness’)
and
primaryObjectTypecode=’8′

And for Change Manager

update sdkmessagefilterbase
set isCustomProcessingStepAllowed=1
where 
sdkmessageid=(select sdkmessageid from sdkmessagebase where name=’setparent’)
and
primaryObjectTypecode=’8′

Bye..

 

CRM 3 to CRM 4 upgrade : two things to keep in mind.


Hi,

We had recently upgraded from CRM 3 to CRM 4. There were two issues we got stuck with.

One was following,

whenever we were saving our sales order form, we were receiving the following error

“One or more of the option values for this picklist are not in the range of allowed values”

However the same thing was working absolutely fine in CRM 3.

Finally we realized that this was because of one of the dummy picklist attribute. Dummy in a sense that for that attribute, values were being displayed using AddOption method of picklist and it had no corresponding (Data) Value defined.

So if a picklist field doesn’t have a corresponding data value defined for it , and if we try to save that form, it would throw this error “One or more of the option values for this picklist are not in the range of allowed values”. But only in case of CRM 4. In CRM 3, it would allow us to save the form.

And the second thing we realized was this,

Suppose we have a custom entity with the following attributes

Name (nvarchar) and Type (picklist) and we have defined a default value for the Type picklist attribute.

Now using CrmService.asmx Web Service if we are creating record of that particular entity and only specifying value for Name attribute,

a new record would get created with name specified by us and for the other picklist field, for which we didn’t specify anything while creating the record, it would have the default value for that picklist attribute set to it . However this would happen only in case of CRM 4.0

For CRM 3, a new record would get created but it would only contain the value for the Name field. The Type field would remain blank as we hadn’t defined any value for creating while creating the record using CrmService.

So in CRM 4, platform layer do take into considerationg the default value set for fields while the record is getting created using CrmService.

Bye.

Customizing Convert Lead dialog box in CRM 4


This is an unsupported customization, where we would be hiding the account option from the convert lead dialog box.

For doing so,

Find and open the conv_lead.aspx page on your crm server.

Inside the function window.onload add the following code

 function window.onload( )
{

// add the following line of code to hide the checkbox
document.getElementById('cbAddAccount').style.display ='none';

and to hide the label by commenting out the following tag

<label for="cbAddAccount">
<% =Microsoft.Crm.CrmEncodeDecode.CrmHtmlEncode(Util.GetFmtObjName
(Util.Account, Util.NameFormatStyle.Singular)) %></label>


Just remember this is unsupported.

Or use the following JavaScript

document.getElementById(‘cbAddAccount’).style.display = “none”;
document.getElementById(‘cbAddAccount’).parentNode.parentNode.childNodes[1].childNodes[0].style.display = “none”;

Bye.