CRM 2016 #Forms #JavaScript #CRM2016 #MoussaElAnnan #Xrm
//Method to get the form context for the record.
//0 Undefined
//1 Create
//2 Update
//3 Read Only
//4 Disabled
//5 Quick Create (Deprecated)
//6 Bulk Edit
//11 Read Optimized (Deprecate;d)
Xrm.Page.ui.getFormType()
//Returns the label of the form.
Xrm.Page.ui.formSelector.getLabel();
//Saves the record asynchronously with the option to set callback functions to be executed after the save operation is completed.
//With Microsoft Dynamics CRM Online 2015 Update 1 or later you can also set an object to control how appointment, recurring appointment, or service activity records are processed.
Xrm.Page.data.save(saveOptions).then(successCallback, errorCallback);
//saveOptions (object)
//With Microsoft Dynamics CRM Online 2015 Update 1 or later the object passed can indicate whether to use the Book or Reschedule messages rather than the Create or Update messages.
//This option is only applicable when used with appointment, recurring appointment, or service activity records.
//If you wish to apply these options, pass the following object as this parameter:
//JavaScript
//{ UseSchedulingEngine: true}
//successCallback Function A function to call when the operation succeeds.
//errorCallback Function A function to call when the operation fails.
//An object with the following properties will be passed:
//errorCode: Number. The error code.
//message: String. A localized error message.
//Asynchronously refreshes and optionally saves all the data of the form without reloading the page.
Xrm.Page.data.refresh(save).then(successCallback, errorCallback);
//save Boolean true if the data should be saved after it is refreshed, otherwise false.
//successCallback Function A function to call when the operation succeeds.
//errorCallback Function A function to call when the operation fails.
//An object with the following properties will be passed:
//errorCode: Number. The error code.
//message: String. A localized error message.
//#Unsupported
$.each($("img"), function() {
var imgId = $(this).attr("id");
if(imgId == "form_pic_image"){
$( this ).replaceWith(function(){
return "<img class='ms-crm-form-pic-image' id='form_pic_image' alt='Edit or remove the picture.' src='" + "../WebResources/gen_Client_logo_LARGE" + "'>";
});
return false
}
});