There are six different operators used in e workflow.
1. Set to: This operator is used to set value of the field of any data type.
2. Append with: This operator can only be used with text field. It will append specified field's value or the default value to the existing value. This operator has introduced in CRM 5.
3. Clear: This operator can be used with all data types. This will clear the field's value.
4. Increment by: This operator can only be used with decimal fields. This will increment the existing value with the specified field's value or default value.
5. Decrement by: This operator can only be used with decimal fields. This will decrement the existing value with the specified field's value or default value.
6. Multiply by: This operator can only be used with decimal fields. This will multiply the existing value with the specified field's value or default value.
Bulk or Mass edit is the great feature in CRM that allows us to edit multiple records at a time. But it will only allows us to set the value, we cannot perform above operations in bulk edit. With the help of workflows, we can perform above operations on multiple records.
Tuesday, September 13, 2011
How to interact with CRM form fields from within the Silverlight page
At times you may have a need to interact with the CRM form to read/update back the latest information after the processing completes from a custom application.
Say we add a button on the Entity form and when user will click on this button then we can read as well as set the value of the entity form fields. Below we have given the example to read the activityparty.
When you click on the button then it will open a child window. To access the CRM form we will need to use the Parent window from which this child window was called. Here we are reading the values of the Sender attribute of the Email.
dynamic win = HtmlPage.Window;
dynamic opener = win.parent.opener;
ScriptObject xrm = (ScriptObject)opener.GetProperty("Xrm");
ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
dynamic dynamicPage = page;
dynamic lookupItems = dynamicPage.data.entity.attributes.get("to").getValue();
HtmlPage.Window.Invoke("readLookup", lookupItems);
“To” attribute is of the type lookup and it will be an array of objects. To read the values for this lookup you need to write the following script on the html page.
function readLookup(source) {
if (source == null) {
return;
}
var array = new Array();
array = source;
for (i = 0; i < array.length; i++) {
alert(array[i].entityType);
alert(array[i].id);
alert(array[i].name);
}
}
Now say you want to update the Subject of the Email from within the Silverlight custom application, you can refer the CRM form and update the controls on the form as shown below
dynamicPage.data.entity.attributes.get("subject").setValue("Test 1234");
Since Subject is a text field it could be done as simply as above.
But to set the value for the lookup and date type of attributes, there is still more to be done. For this we need to add a java script web resource on the required entity. This web resource will contain the function to set the lookup and the date value. We then need to call this function from the Silverlight page. Code below explains how this can be done
dynamic parent = win.parent.opener;
parent.setLookupValue();
he SetLookupValue will contain the code to set the value for the lookup. As given below.
Xrm.Page.data.entity.attributes.get("regardingobjectid").setValue(array);
Hope this helps in designing richer Silverlight applications that interact better with the CRM forms.
Say we add a button on the Entity form and when user will click on this button then we can read as well as set the value of the entity form fields. Below we have given the example to read the activityparty.
When you click on the button then it will open a child window. To access the CRM form we will need to use the Parent window from which this child window was called. Here we are reading the values of the Sender attribute of the Email.
dynamic win = HtmlPage.Window;
dynamic opener = win.parent.opener;
ScriptObject xrm = (ScriptObject)opener.GetProperty("Xrm");
ScriptObject page = (ScriptObject)xrm.GetProperty("Page");
dynamic dynamicPage = page;
dynamic lookupItems = dynamicPage.data.entity.attributes.get("to").getValue();
HtmlPage.Window.Invoke("readLookup", lookupItems);
“To” attribute is of the type lookup and it will be an array of objects. To read the values for this lookup you need to write the following script on the html page.
function readLookup(source) {
if (source == null) {
return;
}
var array = new Array();
array = source;
for (i = 0; i < array.length; i++) {
alert(array[i].entityType);
alert(array[i].id);
alert(array[i].name);
}
}
Now say you want to update the Subject of the Email from within the Silverlight custom application, you can refer the CRM form and update the controls on the form as shown below
dynamicPage.data.entity.attributes.get("subject").setValue("Test 1234");
Since Subject is a text field it could be done as simply as above.
But to set the value for the lookup and date type of attributes, there is still more to be done. For this we need to add a java script web resource on the required entity. This web resource will contain the function to set the lookup and the date value. We then need to call this function from the Silverlight page. Code below explains how this can be done
dynamic parent = win.parent.opener;
parent.setLookupValue();
he SetLookupValue will contain the code to set the value for the lookup. As given below.
Xrm.Page.data.entity.attributes.get("regardingobjectid").setValue(array);
Hope this helps in designing richer Silverlight applications that interact better with the CRM forms.
Subscribe to:
Posts (Atom)