Showing posts from March, 2012

Retrieve Label/Values of Option Set/Two Options Attributes using SQL Script

When you want to retrieve the list of  Label and Values of Option Set and Two Options attributes for SSRS report parameter, documentation, development or whatever purpose, you can query by using the following SQL Script.
You will have to remove/modify the two lines of conditions ("new_testentity" and "new_testoptionsetattribute") accordingly to your requirement.

SELECT Value AS [Text], AttributeValue AS [Value] FROM FilteredStringMap WHERE FilteredViewName = 'Filterednew_testentity' AND AttributeName = 'new_testoptionsetattribute' AND LangId = 1033 -- Language Code, English U.S is 1033 ORDER BY DisplayOrder
This is the alternative query over Schema tables but that won't work in SSRS.

SELECT DISTINCT Entity.LogicalName AS EntitySchemaName , Attribute.LogicalName AS AttributeSchemaName , OptionSet.Name AS OptionSetName , AttributePicklistValue.Value AS OptionValue , LocalizedLabel.L…

Populate Regarding Attribute in New Email Form

When we created a new email for a record by Clicking “New Activity” button in the “Activities” associated view, it will prompt us to select the activity type.

And when the user select E-mail and click OK, the new email form will is shown with the “From” attribute populated with the current user and the “Regarding” attribute populated with the record from which we clicked “New Activity” and everything is fine.

According to the users’ requirement, there’s a case that we have to show the Subgrid of email related to the record on the form. And that’s where the problem started. When the user click “Add New E-mail” button from the Subgrid and the new Email form is loaded, the record is not populated in the regarding attribute. So, the user demands for the same functionality as the new Activity since it would be a hassle to select the Regarding attribute manually.

So, my solution was writing a JavaScript code at the onLoad of the Email form which will auto populate the “Regarding” attribute…

ForceSubmit vs setSubmitMode in CRM 2011 Javascript

Previously, we used
crmForm.all.[fieldname].ForceSubmit = true; in CRM 4.0 to force the CRM system to submit the form data on disabled fields.
But in CRM 2011, the method is changed to
Xrm.Page.getAttribute([fieldname]).setSubmitMode("always"); but the old CRM 4.0 object model is still supported for backward compatibility so that setting true flag to ForceSubmit property seems to be working. But actually, there is a difference between using ForceSubmit and setSubmitMode to save the data in the disabled fields in CRM 2011.
In CRM 2011, there's a method, which returns a Boolean value that indicates if any fields in the form have been modified. When we set true flag to ForceSubmit property of the disabled field, the IsDirty flag of the entity won't be changed when the value of that disabled field is updated from the JavaScript code. But when we use setSubmitMode, the IsDirty flag of the entity will be changed when the value of tha…