Monthly Archives: March 2014

Create new record using current form values in dynamic crm

Currently I am working on a new customization for dynamics CRM customization that requires to copy fields from a form and create a new record using JS.

Copying text or numeric values was easy, like the below :

var attValue = Xrm.Page.data.entity.attributes.get(attname).getValue();

But for Optionset or Money attributes the scenario was different. For those types to copy to you have to do :

var attVal = Xrm.Page.data.entity.attributes.get(attname).getValue();
var newattVal= attVal!=null ? {Value:attVal.toString()}:null;

It meas you have read “Value” from the atttribute to get what you want. Finally yo save a new record with values I read using current form, I utilized the¬†CrmRestKit library like below:

CrmRestKit.Create( 'entityname', listofaatributes, false )
				.fail( function(){
				//console.log('error accoured');
				} 
				)
				.done( function ( data, status, xhr ) { 
				

				} );
Advertisements