web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Field Service forum / Field Service Mobile :...
Field Service forum

Field Service Mobile : Problem : When I add a Product with Price Lists to Work Order, it doesn't setup Unit Amount price to work order product automatically.

(0) ShareShare
ReportReport
Posted on by 5

When I add a Product with Price Lists to Work Order, it doesn't setup Unit Amount price to work order product automatically.

Manual Input is OK. But it isn't cool.

How can I do to setup Unit Amount price to work order product automatically?

I have the same question (0)
  • Suggested answer
    moko33 Profile Picture
    1,788 on at

    Have you created a Price List Item for this product ?

    Have you used the same price list for this Work Order?

    If both is yes: there is a bug in FieldService 8.7 which causes that the Unit Amount is not pulled. Try to upgrade to Field Service 8.8 and check if the problem is still there

  • Ryota Uehara Profile Picture
    5 on at

    Thanks moko33!

    Both is Yes.

    And I upgrade to Field Service 8.8 and made sure that the Unit Amount is pulled! (Online Only, Offline doesn't)

    Q1. Is it a specification that the Unit Amount is not pulled in Offline mode?

    In Online, when the Unit Amount is pulled, Unit Amount Price (Estimate Unit Amount) is set '0'.

    And I save it, it isn't changed.

    I clear Unit Amount Price before i save it, and save it, it is changed.

    I try the same thing on the Web Browser(Not on Field Service Mobile), Unit Amount Price is set Blank. And I save it, it is changed.

    Q2. Is it an another bug?

  • Suggested answer
    moko33 Profile Picture
    1,788 on at

    Hi Ryota,

    I tried to simulate what you have found and I was able to reproduce it on FS Mobile. To me this looks like a bug as well.

    Here are my test results:

    In Online Mode:

    1. create new WO Product with Line Status "Estimated", recognize: "Estimated Unit Amount" is automatically set to 0,00.

    2. when I clear the "Estimate Unit Amount", than save, the system pulls the correct price

    --

    1. new WO Product, line status Used, Estimated Unit Amount is automatically set to 0,00 and "Unit Amount" is automatically set to 0,00.

    2. when I clear the Estimate Unit Amount, than save, system pulls the correct price for Estimated Unit Amount, but in "Unit Amount" the 0,00 stays.

    3. when I additionally clear the "Unit Amount" before saving than I cannot save anymore because "Unit Amount" is a mandatory field for Line Status "Used"

    In Offline Mode:

    neither the Unit Amount nor the Estimated Unit Amount gets pulled, even if the Price List and the Price List Items are available am Mobile in offline mode.

    Exact same behaviour with WO Services.

    To me it should be like this:

    Price gets pulled into "(Estimated) Unit Amount" for both Line Statuses (Estimated and Used) as it is in Browser, even when FS Mobile is in offline mode.

    But I can't tell you if that was working in the past. Maybe Microsoft can help us here?

  • Verified answer
    Al Iggs Profile Picture
    Microsoft Employee on at

    In the "old" FS App we were doing subtotal and total calculations in the app C# code for offline. With the current FS App we moved all this logic into JS in the mobile project. The downside is that JavaScript does not play nicely with calculations when it comes to all sorts of different currencies. As such, we have moved away from supporting WO product/service total/subtotal calculations due to the limitations of JavaScript when it comes to precise calculations. JavaScript makes use of 64-bit floating point representation, which introduces complications when performing calculations that must be precise. Also the new entitlement functionality would need significant effort for calculations to be performed offline, that's why this is not supported either.

    What is the scenario you are looking for where the tech NEEDS the total calculated offline?

    I have reached out to the PM to see if we can update the documentation.

  • Ryota Uehara Profile Picture
    5 on at

    Thx moko33.

    I'm glad to investigate the problem.

    I made an inquiry to Microsoft support, but Alexander Heinze got an answer first!

  • Ryota Uehara Profile Picture
    5 on at

    Thank you for answering.

    I asked a question because the functions that can be realized in FS can not be realized in FS mobile.

    >I have reached out to the PM to see if we can update the documentation.

    It would be helpful if you could mention the differences between FS and FS mobile in Microsoft Docs.

  • Suggested answer
    moko33 Profile Picture
    1,788 on at

    Hello Alexander and Ryota. I just had an extensive session with a Field Service Mobile Engineer from Microsoft US. He provided me with a JS script that fixes the issue reported by Ryota. He said it would be officially released by MS in a future update of the Mobile Project.

  • graflunds Profile Picture
    on at

    Moko,

    we are having issues with this as well.  i found out that clearing the $0.00 in the unit amount and then saving does populate the price as well.

    Can you email me or get me a copy of the .js that Microsoft gave you for a fix?

  • moko33 Profile Picture
    1,788 on at

    Sure, can send you the script. Let me just find out again, how the deployment needs to be done. There was a trick for it.

  • Suggested answer
    moko33 Profile Picture
    1,788 on at

    Put the code below in an empty txt-File and save it as "WorkOrderHelper.js".

    Than open your customization Mobile Project in Woodford (typically a derive of that one provided by Microsoft).

    Go to Offline HTML=>Open folder "WorkOrder".

    There you'll find a "WorkOrderHelper.js". Replace (overwrite) this with the new one.

    If having trouble to overwrite/delete the old version (locked file), try to edit it slightly and than overwrite it afterwards.

    Here is the script:

    var FS = FS || {};

    FS.WorkOrderHelper = {

       // Sets the Work Order Product or Service's fields onLoad

       setLoadValues: function (entityForm, schemaName) {

           if (entityForm && entityForm.entity && entityForm.entity.properties) {

               var entityProperties = entityForm.entity.properties;

               if (entityProperties[schemaName.properties.msdyn_priceList] == null) {

                   FS.WorkOrderHelper.setDefaultValuesFromWorkOrder(entityForm.entity, schemaName);

               }

               if (entityProperties[schemaName.properties.msdyn_workOrderIncident] == null) {

                   FS.WorkOrderHelper.setWorkOrderIncident(entityForm.entity, schemaName);

               }

               if (entityProperties[schemaName.properties.msdyn_customerAsset] == null) {

                   FS.WorkOrderHelper.setCustomerAsset(entityForm.entity, schemaName);

               }

               if (entityForm.entity.entityName === FS.Schema.WorkOrderProduct.name) {

                   if (entityForm.entity.isNew && entityProperties[FS.Schema.WorkOrderProduct.properties.msdyn_warehouse] == null) {

                       FS.WorkOrderProduct.setWarehouse(entityForm.entity);

                   }

               }

           }

       },

       // Sets the Work Order Product or Service's Discount Amount, Discount Percent, Quantity, and Unit Amount fields when the Line Status changed from Estimated to Used

       checkEstimateToUsedChanged: function (entity, schemaName, initial) {

           if (entity && entity.properties) {

               var used, estimated;

               if (entity.entityName === FS.Schema.WorkOrderProduct.name) {

                   used = FS.Enums.msdyn_workorderproductmsdyn_LineStatus.Used;

                   estimated = FS.Enums.msdyn_workorderproductmsdyn_LineStatus.Estimated;

               }

               else if (entity.entityName === FS.Schema.WorkOrderService.name) {

                   used = FS.Enums.msdyn_workorderservicemsdyn_LineStatus.Used;

                   estimated = FS.Enums.msdyn_workorderservicemsdyn_LineStatus.Estimated;

               }

               var lineStatus = entity.properties[schemaName.properties.msdyn_lineStatus];

               if (!entity.isNew && lineStatus === used && initial === estimated) {

                   if (entity.entityName === FS.Schema.WorkOrderProduct.name) {

                       FS.WorkOrderHelper.copyAndNullifyIfNeeded(entity, [{ pricingAttribute: FS.Schema.WorkOrderProduct.properties.msdyn_quantity, estimateAttribute: FS.Schema.WorkOrderProduct.properties.msdyn_estimateQuantity }]);

                   }

                   else if (entity.entityName === FS.Schema.WorkOrderService.name) {

                       FS.WorkOrderHelper.copyAndNullifyIfNeeded(entity, [{ pricingAttribute: FS.Schema.WorkOrderService.properties.msdyn_duration, estimateAttribute: FS.Schema.WorkOrderService.properties.msdyn_estimateDuration }]);

                   }

                   FS.WorkOrderHelper.copyAndNullifyIfNeeded(entity, [

                       { pricingAttribute: schemaName.properties.msdyn_discountAmount, estimateAttribute: schemaName.properties.msdyn_estimateDiscountAmount },

                       { pricingAttribute: schemaName.properties.msdyn_discountPercent, estimateAttribute: schemaName.properties.msdyn_estimateDiscountPercent },

                       { pricingAttribute: schemaName.properties.msdyn_unitAmount, estimateAttribute: schemaName.properties.msdyn_estimateUnitAmount },

                       { pricingAttribute: schemaName.properties.msdyn_unitCost, estimateAttribute: schemaName.properties.msdyn_estimateUnitCost }

                   ]);

               }

           }

       },

       copyAndNullifyIfNeeded: function (entity, pairs) {

           for (var i = 0; i < pairs.length; i++) {

               entity.properties[pairs[i].pricingAttribute] = entity.properties[pairs[i].estimateAttribute] || null;

           }

       },

       // Clears the values in the Pricing tab if Line Status is Estimated

       clearPricingTab: function (entity, schemaName) {

           if (entity && entity.properties) {

               var lineStatus = entity.properties[schemaName.properties.msdyn_lineStatus];

               var estimated;

               if (entity.entityName === FS.Schema.WorkOrderProduct.name) {

                   estimated = FS.Enums.msdyn_workorderproductmsdyn_LineStatus.Estimated;

               }

               else if (entity.entityName === FS.Schema.WorkOrderService.name) {

                   estimated = FS.Enums.msdyn_workorderservicemsdyn_LineStatus.Estimated;

               }

               if (lineStatus === estimated) {

                   if (entity.entityName === FS.Schema.WorkOrderProduct.name) {

                       entity.properties[schemaName.properties.msdyn_quantity] = null;

                       entity.properties[schemaName.properties.msdyn_qtyToBill] = null;

                   }

                   else if (entity.entityName === FS.Schema.WorkOrderService.name) {

                       entity.properties[schemaName.properties.msdyn_minimumChargeAmount] = null;

                       entity.properties[schemaName.properties.msdyn_minimumChargeDuration] = null;

                   }

                   entity.properties[schemaName.properties.msdyn_unitAmount] = null;

                   entity.properties[schemaName.properties.msdyn_subtotal] = null;

                   entity.properties[schemaName.properties.msdyn_discountPercent] = null;

                   entity.properties[schemaName.properties.msdyn_discountAmount] = null;

                   entity.properties[schemaName.properties.msdyn_totalAmount] = null;

                   entity.properties[schemaName.properties.msdyn_unitCost] = null;

                   entity.properties[schemaName.properties.msdyn_additionalCost] = null;

                   entity.properties[schemaName.properties.msdyn_commissionCosts] = null;

                   entity.properties[schemaName.properties.msdyn_totalCost] = null;

               }

           }

       },

       // Sets the Work Order Product or Service's Description, Taxable, Name, and Unit fields

       setDefaultValuesFromProduct: function (entity, schemaName, value) {

           if (entity && entity.properties) {

               var entityField = entity.properties[value];

               if (entityField) {

                   var fetchEntity = new MobileCRM.FetchXml.Entity(FS.Schema.Product.name);

                   fetchEntity.addAttribute(FS.Schema.Product.properties.description); // index 0

                   fetchEntity.addAttribute(FS.Schema.Product.properties.msdyn_taxable); // index 1

                   fetchEntity.addAttribute(FS.Schema.Product.properties.name); // index 2

                   fetchEntity.addAttribute(FS.Schema.Product.properties.defaultUoMId); // index 3

                   fetchEntity.filter = new MobileCRM.FetchXml.Filter();

                   fetchEntity.filter.where(FS.Schema.Product.properties.productId, "eq", entityField.id);

                   var fetch = new MobileCRM.FetchXml.Fetch(fetchEntity);

                   fetch.execute("Array",

                       function (results) {

                           if (results && results.length > 0) {

                               var fetchedProduct = results[0];

                               if (fetchedProduct) {

                                   MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

                                       entityForm.entity.properties[schemaName.properties.msdyn_description] = fetchedProduct[0];

                                       entityForm.entity.properties[schemaName.properties.msdyn_taxable] = fetchedProduct[1] == "True";

                                       entityForm.entity.properties[schemaName.properties.msdyn_name] = fetchedProduct[2];

                                       entityForm.entity.properties[schemaName.properties.msdyn_unit] = fetchedProduct[3];

                                   }, MobileCRM.bridge.alert);

                               }

                           }

                       }, MobileCRM.bridge.alert, null);

               }

           }

       },

       // Sets the Work Order Product's Price List and Currency fields

       setDefaultValuesFromWorkOrder: function (entity, schemaName) {

           if (entity && entity.properties) {

               var workOrder = entity.properties[schemaName.properties.msdyn_workOrder];

               if (workOrder) {

                   var fetchEntity = new MobileCRM.FetchXml.Entity(FS.Schema.WorkOrder.name);

                   fetchEntity.addAttribute(FS.Schema.WorkOrder.properties.msdyn_priceList); // index 0

                   fetchEntity.addAttribute(FS.Schema.WorkOrder.properties.transactionCurrencyId); // index 1

                   fetchEntity.filter = new MobileCRM.FetchXml.Filter();

                   fetchEntity.filter.where(FS.Schema.WorkOrder.properties.woNumber, "eq", workOrder.id);

                   var fetch = new MobileCRM.FetchXml.Fetch(fetchEntity);

                   fetch.execute("Array",

                       function (results) {

                           if (results && results.length > 0) {

                               var fetchedWorkOrder = results[0];

                               if (fetchedWorkOrder) {

                                   MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

                                       entityForm.entity.properties[schemaName.properties.msdyn_priceList] = fetchedWorkOrder[0];

                                       entityForm.entity.properties[schemaName.properties.transactionCurrencyId] = fetchedWorkOrder[1];

                                   }, MobileCRM.bridge.alert);

                               }

                           }

                       }, MobileCRM.bridge.alert, null);

               }

           }

       },

       // Sets the Work Order Product or Service's Customer Asset field

       setCustomerAsset: function (entity, schemaName) {

           if (entity && entity.properties) {

               var customerAsset = entity.properties[schemaName.properties.msdyn_customerAsset];

               //Only Set if current CustomerAsset has not been set

               if (customerAsset == null) {

                   var workOrderIncident = entity.properties[schemaName.properties.msdyn_workOrderIncident];

                   // Set the CustomerAsset of WorkOrderIncident that is on this Work Order Product or Service

                   if (workOrderIncident) {

                       FS.WorkOrderHelper.fetchWorkOrderIncidents(workOrderIncident.id, [FS.Schema.WorkOrderIncident.properties.msdyn_customerAsset], FS.Schema.WorkOrderIncident.properties.msdyn_workOrderIncidentId,

                           function (results) {

                               if (results && results.length > 0) {

                                   var fetchedWOIncident = results[0];

                                   if (fetchedWOIncident) {

                                       MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

                                           entityForm.entity.properties[schemaName.properties.msdyn_customerAsset] = fetchedWOIncident[0];

                                       }, MobileCRM.bridge.alert);

                                   }

                               }

                           }, MobileCRM.bridge.alert, null);

                   }

                   else { //Set the CustomerAsset of the first (non-primary) WorkOrderIncident from the same WorkOrder that is on this Work Order Product or Service

                       var workOrder = entity.properties[schemaName.properties.msdyn_workOrder];

                       if (workOrder) {

                           FS.WorkOrderHelper.fetchWorkOrderIncidents(workOrder.id, [FS.Schema.WorkOrderIncident.properties.msdyn_customerAsset], FS.Schema.WorkOrderIncident.properties.msdyn_workOrder,

                               function (results) {

                                   if (results && results.length > 0) {

                                       var fetchedWOIncident = results[0];

                                       if (fetchedWOIncident && fetchedWOIncident[0]) {

                                           MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

                                               entityForm.entity.properties[schemaName.properties.msdyn_customerAsset] = fetchedWOIncident[0];

                                           }, MobileCRM.bridge.alert);

                                       }

                                   }

                               }, MobileCRM.bridge.alert, null);

                       }

                   }

               }

           }

       },

       // Sets the Work Order Product or Service's Work Order Incident field

       setWorkOrderIncident: function (entity, schemaName) {

           if (entity && entity.properties) {

               var workOrder = entity.properties[schemaName.properties.msdyn_workOrder];

               if (workOrder) {

                   FS.WorkOrderHelper.fetchWorkOrderIncidents(workOrder.id, [FS.Schema.WorkOrderIncident.properties.msdyn_workOrderIncidentId, FS.Schema.WorkOrderIncident.properties.msdyn_name], FS.Schema.WorkOrderIncident.properties.msdyn_workOrder,

                       function (results) {

                           if (results && results.length === 1) {

                               //results[0][0] is the msdyn_workOrderIncidentId field and results[0][1] is the msdyn_name field

                               var workOrderIncidentReference = new MobileCRM.Reference(FS.Schema.WorkOrderIncident.name, results[0][0], results[0][1]);

                               MobileCRM.UI.EntityForm.requestObject(function (entityForm) {

                                   entityForm.entity.properties[schemaName.properties.msdyn_workOrderIncident] = workOrderIncidentReference;

                               }, MobileCRM.bridge.alert);

                           }

                       }, MobileCRM.bridge.alert, null);

               }

           }

       },

       fetchWorkOrderIncidents: function (id, attributes, fetchType, success, failure, scope) {

           var fetchEntity = new MobileCRM.FetchXml.Entity(FS.Schema.WorkOrderIncident.name);

           for (var i = 0; i < attributes.length; i++) {

               fetchEntity.addAttribute(attributes[i]);

           }

           fetchEntity.filter = new MobileCRM.FetchXml.Filter();

           fetchEntity.filter.where(fetchType, "eq", id);

           var fetch = new MobileCRM.FetchXml.Fetch(fetchEntity);

           fetch.execute("Array", success, failure, scope);

       }

    };

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Field Service

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans