Hi,
Found this wonderful article on how to set the permissions within Microsoft Dynamics CRM
http://www.orbitone.com/en/blog/archive/2009/10/06/minimum-dynamics-crm-permissions.aspx
Bye..
Hi,
Found this wonderful article on how to set the permissions within Microsoft Dynamics CRM
http://www.orbitone.com/en/blog/archive/2009/10/06/minimum-dynamics-crm-permissions.aspx
Bye..
Hi,
Just a sample code for updating a picklist attribute for an entity instance.
public void Execute(IPluginExecutionContext context)
{
DynamicEntity entity = (DynamicEntity)context.InputParameters.Properties["Target"];
if (entity.Name == "new_test")
{
// Post Create event so get the guid from Output Parameters
Guid testId = (Guid)context.OutputParameters.Properties["id"];
ICrmService crmService = context.CreateCrmService(true);
DynamicEntity myTest = new DynamicEntity();
myTest.Name = "EntityName";
// Set the key property
KeyProperty myTestGuid = new KeyProperty();
myTestGuid.Name = "EntityPrimaryKeyID";
Key myTestKey=new Key();
myTestKey.Value = testId;
myTestGuid.Value = myTestKey;
myTest.Properties.Add(myTestGuid);
// Picklist property to be updated
PicklistProperty myPP = new PicklistProperty();
myPP.Name = "new_picklist";
myPP.Value = new Picklist();
myPP.Value.name = "nameOfThePicklistValue";
// picklist value
myPP.Value.Value = 2;
myTest.Properties.Add(myPP);
try
{
crmService.Update(myTest);
}
catch (SoapException ex)
{
TextWriter log1 = TextWriter.Synchronized(File.AppendText(@"C:\g.txt"));
log1.WriteLine("MyMessage exception :-" + ex.Detail.InnerXml );
log1.Close();
}
}
}
}
Bye…
For an account record, the associated view of Contract would have default filter set as Draft. So if we want to change it to some other status for example “Active” we can make use of the following JavaScript for that.
This JavaScript is based on the popular JavaScript code used for hiding “add existing button”
Please check this wonderful article
http://blog.davehawes.com/post/2008/04/23/MSCRM-4-Remove-Add-Existing-xxxxx-button.aspx
The JavaScript code for changing default option
var navElement = document.getElementById('navContracts');
if (navElement != null) {
navElement.onclick = function LoadAreaOverride() {
loadArea('areaContracts');
SetDefaultOption(document.getElementById('areaContractsFrame'));
}
}
function SetDefaultOption(Iframe) {
if (Iframe != null ) {
Iframe.onreadystatechange = function SetOption() {
if (Iframe.readyState == 'complete') {
var iFrame = frames[window.event.srcElement.id];
var selectBox=iFrame.document.getElementById('statecode');
selectBox.options[2].selected=true;
}
}
}
http://social.microsoft.com/Forums/en-US/crmdevelopment/thread/85615ccd-b8e9-48d3-a906-4fd7b301dac0
Bye..
Suppose we have written a simple workflow activity that references values for the above Images and have registered it on create of lead record.
The attributes included within the images would be following
| Record is created | Lead |
| PrimaryEntityImage | fullname |
| leadid | |
| owningbusinessunit | |
| PrimaryEntityPreImage | null |
| PrimaryEntityPostImage | leadid |
| owningbusinessunit | |
| ownerid | |
Now suppose we register it on Record attribute change and select city and description for lead.
Now suppose we specify value for those fields and save the record. Here the values for the images would be
| Record attributes change | Lead |
| PrimaryEntityImage | fullname |
| leadid | |
| owningbusinessunit | |
| PrimaryEntityPreImage | fullname |
| leadid | |
| owningbusinessunit | |
| ownerid | |
| PrimaryEntityPostImage | leadid |
| owningbusinessunit | |
| ownerid | |
Except for values in PrimaryEntityPreImage there is hardly any change in the Images.
Now lets modify the workflow and add a check condition step that would check if both the city and description field contains data for lead.
Now after modifying the values for city and description field for a lead ,these are the values we get in the images.
| Record attributes change (after check condition) | Lead |
| PrimaryEntityImage | fullname |
| leadid | |
| owningbusinessunit | |
| address1_city | |
| description | |
| PrimaryEntityPreImage | fullname |
| leadid | |
| owningbusinessunit | |
| ownerid | |
| address1_city | |
| description | |
| PrimaryEntityPostImage | leadid |
| owningbusinessunit | |
| ownerid |
Address1_city and Description field has got added for PrimaryEntityImage and PrimaryEntityPreImage.
Now if we remove check condition for city field for lead,
| Record attributes change (after check condition) | Lead |
| PrimaryEntityImage | fullname |
| leadid | |
| owningbusinessunit | |
| description | |
| PrimaryEntityPreImage | fullname |
| leadid | |
| owningbusinessunit | |
| ownerid | |
| description | |
| PrimaryEntityPostImage | leadid |
| owningbusinessunit | |
| ownerid |
We could see that address1_city is not there in the images.
Now lets further modify our workflow, remove the check condition and add a step to create an account record and set dynamic values for fields in account using the industrycode and emailaddress1 field of the lead record.
| Record attributes change (Step for Creating Record) | Lead |
| PrimaryEntityImage | fullname |
| leadid | |
| owningbusinessunit | |
| industrycode | |
| emailaddress1 | |
| PrimaryEntityPreImage | fullname |
| leadid | |
| owningbusinessunit | |
| ownerid | |
| industrycode | |
| emailaddress1 | |
| PrimaryEntityPostImage | leadid |
| owningbusinessunit | |
| ownerid |
We can see that both these fields are added to images.
And here PrimaryEntityPreImage would contain the values for the field before they were modified and and PrimaryEntityImages would contain the modified values for those field. The PrimaryEntityPostImage would not have these attributes inside it.
So it proves that an attribute would be included in the entity images if we are referencing that property in our Check Condition or as a dynamic value within the workflow.
Bye.
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
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..