Quantcast
Channel: Microsoft Dynamics CRM
Viewing all 154803 articles
Browse latest View live

Forum Post: Refresh When Xrm.WebApi.updateRecord finishing Execution

$
0
0
Hello i am trying to refresh a sub-grid when my script finishing updating relating records but the problem is my sub-grid refresh before all updates finish i have to refresh my sub-grid manually multiple times to see all my updates is there any way i can be sure that Xrm.WebApi.updateRecord finished executing in the server side, i know there is success call back function but it doesn't fulfill my need because it triggers after the request is finished not the execution in my server side then i came with another solution to delay my script using settimeout function but i don't think is consistent sometimes work and other don't here is an example from my code function updateProducts(context){ var formContext = context.getFormContext(); var isDirty = formContext.data.entity.getIsDirty(); if(!isDirty){ Xrm.Utility.showProgressIndicator("Please wait..."); var result; var myCollection = []; var entityId = Xrm.Page.data.entity.getId(); entityId = entityId.replace("}", "").replace("{", "") var lookupMetier = Xrm.Page.getAttribute("tool_metier").getValue(); var lookupPartenaire = Xrm.Page.getAttribute("msa_partnerid").getValue(); var nameMetier ; var guidMetier ; var entTypeMetier; var namePartenaire ; var guidPartenaire; var entTypePartenaire; if (lookupMetier != null) { nameMetier = lookupMetier[0].name; guidMetier = lookupMetier[0].id; guidMetier = guidMetier.replace("}", "").replace("{", "") entTypeMetier = lookupMetier[0].entityType; } if (lookupPartenaire != null) { namePartenaire = lookupPartenaire[0].name; guidPartenaire = lookupPartenaire[0].id; guidPartenaire = guidPartenaire.replace("}", "").replace("{", "") entTypePartenaire = lookupPartenaire[0].entityType; } parent.Xrm.WebApi.retrieveMultipleRecords("opportunityproduct", "?$select=opportunityproductid,tool_prix1&$filter=_tool_metier_value eq "+guidMetier+" and _tool_partenaire_value eq "+guidPartenaire+" and _opportunityid_value eq "+entityId+"").then( function success(result) { for (var i = 0; i < result.entities.length; i++) { var tauxDeMarge = Xrm.Page.getAttribute("tool_tauxdemarge").getValue(); var tauxDevise = Xrm.Page.getAttribute("tool_tauxdevise").getValue(); var fraisDapproche = Xrm.Page.getAttribute("tool_fraisdapproche").getValue(); var prixDachat = result.entities[i].tool_prix1; var remise = Xrm.Page.getAttribute("tool_remise").getValue(); var var0 = remise/100; var var1 = 1-var0; var var2 = 1+tauxDeMarge; var var3 = (prixDachat*var1*var2)+prixDachat; var data = { "tool_fraisdapproche": fraisDapproche, "tool_tauxdemarge": tauxDeMarge, "tool_tauxdevise": tauxDevise, "tool_remise": remise, "tool_prixdevente": var3, } Xrm.WebApi.updateRecord("opportunityproduct", result.entities[i].opportunityproductid, data) } }, function (error) { console.log(error.message); // handle error conditions } ); setTimeout(function(){ Xrm.Page.getControl("opportunityproductsGrid").refresh(); },10000); Xrm.Utility.closeProgressIndicator(); } else { var alertStrings = {confirmButtonLabel: "Save", text: "Please save before Update your products !" }; var alertOptions = { height: 190, width: 360 }; Xrm.Navigation.openAlertDialog(alertStrings,alertOptions).then(saveForm,errorCallback); } // Xrm.Utility.openWebResource("new_simple_modal", null, 250, 250); /* var DialogOption = new Xrm.DialogOptions; DialogOption.width = 500; DialogOption.height = 620; window.parent.Xrm.Internal.openDialog("/WebResources/tool_modalDialog", DialogOption, null, null, null);*/ } function saveForm(){ Xrm.Page.data.save(); }

Blog Post: Tip #1181: Filtered lookups on editable grids

$
0
0
Today’s tip is from Nick “Benchpress” Doelman . Technically it’s from his wife which proves that all of us, MVPs, are mere mortals and the real knowledge still belongs to the users. She only wanted to see contacts that belonged to an account on the record but the lookup view was showing all the contacts. Turns out, the editable grid lookup will only filter if the ‘filter by’ field is also on the view. For instance: Without the “Account” being visible on the editable grid view: Now with the “Account” being added to the editable grid view: Don’t have a tip but your spouse works with Dynamics? Ask them and send the tip to jar@crmtipoftheday.com ! ( Facebook and Twitter cover photo by Tyler Nix on Unsplash )

Forum Post: RE: Js Web Resource executes 2 times

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
This is not a expected behavior . where did you register your function? is it OOB on-load event ? Please share your code and screenshot here .

Forum Post: RE: Refresh Form

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
// A namespace defined for the sample code // As a best practice, you should always define // a unique namespace for your libraries var Sdk = window.Sdk || {}; (function () { // Code to run in the form OnLoad event this.formOnLoad = function (executionContext) { console.log("disable button web resource"); var formContext = executionContext.getFormContext(); var selectedStage = formContext.data.process.getSelectedStage(); var selectedStageName = selectedStage.getName(); if (selectedStageName == "RF Review") { parent.document.getElementById("stageAdvanceActionContainer").style.display = "none"; parent.document.getElementById("stageBackActionContainer").style.display = "none"; } console.log("after getting form context"); var processObj = formContext.data.process.getActiveProcess(); var processName = processObj.getName(); console.log("after getting process name"); console.log(processName); console.log("before if"); if(processName == "Case to Work Order Business Process") { formContext.data.process.setActiveProcess("f51baaeb-f184-4ffa-bf98-19c2891afa67",callBackFunction); } console.log("after assigning id"); formContext.data.entity.save(); console.log("after save"); } function callBackFunction(result){ } }).call(Sdk);

Forum Post: get GUID of the selected record of a lookup field

$
0
0
dear all i do have a lead-lookup field placed on opportunity entity, in (NEW) opportunity, the user has to select the proper lead from this field and then save the opportunity. I need to know the record GUID of that selected lead in the lookup field. thanks,

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
Hi, This is because you are calling formContext.data.entity.save(); method inside the onload function. When you are doing Save in onload which is calling Onload functionits expected form will reload again and thats why its getting fired two time . when you save records that means page will always reload and call all the onload function. For the first time Onload will call and second time when page get saved. // A namespace defined for the sample code // As a best practice, you should always define // a unique namespace for your libraries var Sdk = window.Sdk || {}; (function () { // Code to run in the form OnLoad event this.formOnLoad = function (executionContext) { console.log("disable button web resource"); var formContext = executionContext.getFormContext(); var selectedStage = formContext.data.process.getSelectedStage(); var selectedStageName = selectedStage.getName(); if (selectedStageName == "RF Review") { parent.document.getElementById("stageAdvanceActionContainer").style.display = "none"; parent.document.getElementById("stageBackActionContainer").style.display = "none"; } console.log("after getting form context"); var processObj = formContext.data.process.getActiveProcess(); var processName = processObj.getName(); console.log("after getting process name"); console.log(processName); console.log("before if"); if(processName == "Case to Work Order Business Process") { formContext.data.process.setActiveProcess("f51baaeb-f184-4ffa-bf98-19c2891afa67",callBackFunction); } console.log("after assigning id"); formContext.data.entity.save(); console.log("after save"); } function callBackFunction(result){ } }).call(Sdk)

Forum Post: RE: Updating a lookup in a custom entity through plugin

$
0
0
Do iterate any nested collections in your code ??

Forum Post: RE: Refresh Form

$
0
0
@somayeh: Which approach suggested by Gautam resolved your issue: 1st one, 2nd one or both?

Forum Post: RE: get GUID of the selected record of a lookup field

$
0
0
Hi Ahmad , Try with this - function OnChangeLead() { if (Xrm.Page.getControl("LeadLookupId") != null && Xrm.Page.getControl("LeadLookupId").getAttribute().getValue() != null) { var LeadObj = Xrm.Page.getControl("LeadLookupId").getAttribute().getValue(); var name = LeadObj[0].name; var Leadid = LeadObj[0].id; } }

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
After removing this problem is same issue not resolved. It is executing 2 times again.

Forum Post: RE: get GUID of the selected record of a lookup field

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
Try to remove below line - formContext.data.process.setActiveProcess("f51baaeb-f184-4ffa-bf98-19c2891afa67",callBackFunction);

Forum Post: RE: Updating a lookup in a custom entity through plugin

$
0
0
Hi, That issue has changed to a new one.. Now, on creating record and on clicking on save, it continously goes on and doesn't save.I don't know where its gone in an infinite loop or what?

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
but i cannot do this because i have to switch process on form load

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
and as i remember before including this line issue js was executing 2 times

Forum Post: RE: Refresh When Xrm.WebApi.updateRecord finishing Execution

$
0
0
Hi Instead of trying with timeouts (which will be wrong a lot of the times since the total time taken for your requests might vary) you should add a success method to the call Xrm.WebApi.updateRecord. At the final loop in your for-loop, this success method can then call the refesh method. At that Point you know that all updates are finished.

Forum Post: RE: Js Web Resource executes 2 times

$
0
0
Just for trial to check whether this is the root cause or not . In addition you can comment out all the code inside the function and check how many time its executing. // A namespace defined for the sample code // As a best practice, you should always define // a unique namespace for your libraries var Sdk = window.Sdk || {}; (function () { // Code to run in the form OnLoad event this.formOnLoad = function (executionContext) { console.log("disable button web resource"); //var formContext = executionContext.getFormContext(); //var selectedStage = formContext.data.process.getSelectedStage(); //var selectedStageName = selectedStage.getName(); //if (selectedStageName == "RF Review") //{ // parent.document.getElementById("stageAdvanceActionContainer").style.display = "none"; // parent.document.getElementById("stageBackActionContainer").style.display = "none"; //} //console.log("after getting form context"); //var processObj = formContext.data.process.getActiveProcess(); //var processName = processObj.getName(); //console.log("after getting process name"); //console.log(processName); //console.log("before if"); //if(processName == "Case to Work Order Business Process") //{ // formContext.data.process.setActiveProcess("f51baaeb-f184-4ffa-bf98-19c2891afa67",callBackFunction); //} //console.log("after assigning id"); //formContext.data.entity.save(); //console.log("after save"); } function callBackFunction(result){ } }).call(Sdk);

Forum Post: RE: Refresh When Xrm.WebApi.updateRecord finishing Execution

$
0
0
i already tested this solution but it refresh before updates finishes execution on the server side
Viewing all 154803 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>