Skip to main content

Notifications

Service | Customer Service, Contact Center, Fie...
Answered

How to change the Scan Customer Asset attribute on Field Service Mobile App?

Posted on by 90

We want To change the function of Scan Customer Asset to look for a customer asset attribute other than the GUID  as it will by default scan the barcode and matches the barcode with GUID of the Customer Asset

We followed the below link but we cannot download the (ScanCustomerAsset.JS) file from Woodford and we don't know how can we change that behavior. 

docs.microsoft.com/.../mobile-faq

  • CSafwat Profile Picture
    CSafwat 90 on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    It worked with me. Thank you.

  • Verified answer
    Al Iggs Profile Picture
    Al Iggs on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    I simply went to Offline HTML in the explorer, selected the file, edited it, saved it, done. I also tried uploading the .JS file using the upload button in Offline HTML. Worked as well.

  • CSafwat Profile Picture
    CSafwat 90 on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    When trying to import the single Offline HTML file, the other Offline HTML file are deleted. So, how to import the file?

  • Al Iggs Profile Picture
    Al Iggs on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    Why did you have to import the project? Should be enough to just modify the single Offline HTML file.

  • CSafwat Profile Picture
    CSafwat 90 on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    Hello Alexander,

    I changed the file but when I am trying to import the project again I got thus error "Exception: Invalid mobile project: resco.xcrm not found"  do you have any idea how can I fix this error??

  • Verified answer
    Al Iggs Profile Picture
    Al Iggs on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    You can simply download the Woodford project from aka.ms/fsmobile-project and get the JS file as explained above.

  • CSafwat Profile Picture
    CSafwat 90 on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    Hello Alexander, thanks for your reply.

    Whenever I try to download the JS file from Offline HTML I got this error "TypeError: Cannot read property 'async' of undefined". Do you know how can I fix this as I don't have the original .Woodford file now so I cannot do the workaround.

  • Verified answer
    Al Iggs Profile Picture
    Al Iggs on at
    RE: How to change the Scan Customer Asset attribute on Field Service Mobile App?

    Here is a piece of code that will use a custom field instead of the GUID. Note that the code was just created for testing, i.e. no error handling.

    You should be able to download the JS file from the Offline HTML section, modify it and upload again. Does that not work for you? Workaround would be to take the original .woodford file that you download from Microsoft, rename it to .zip, open it and navigate to www.zip\CustomerAsset. Update the code and upload in Woodford.

    // code assumes that the serial number is stored in a field "sie_barcode" on the customer asset

    var FS = FS || {};

    FS.ScanCustomerAsset = {
    localization: null,
    scanCustomerAssetButtonId: "ScanCustomerAssetButton",

    customerAssetOnLoad: function (goNow) {
    MobileCRM.Localization.initialize(FS.ScanCustomerAsset.storeLocalization, MobileCRM.bridge.alert);
    FS.ScanCustomerAsset.changeButtonColor();
    MobileCRM.UI.IFrameForm.requestObject(function (iFrame) {
    if (iFrame && iFrame.form && iFrame.form.caption)
    iFrame.form.caption = "";
    }, MobileCRM.bridge.alert, null);
    if (goNow) {
    FS.ScanCustomerAsset.scanCustomerAsset();
    }
    },

    changeButtonColor: function () {
    // Overrides default white background and black text to the apps styles
    MobileCRM.Application.getAppColor("TitleBackground", function (backgroundColor) {
    MobileCRM.Application.getAppColor("TitleForeground", function (foregroundColor) {
    if (backgroundColor && foregroundColor) {
    var element = document.getElementById(FS.ScanCustomerAsset.scanCustomerAssetButtonId);
    if (element) {
    element.style.backgroundColor = backgroundColor;
    element.style.color = foregroundColor;
    element.style.borderColor = backgroundColor;
    }
    }
    }, MobileCRM.bridge.alert);
    }, MobileCRM.bridge.alert);
    },

    scanCustomerAsset: function () {
    MobileCRM.Platform.scanBarCode(function (res) {
    if (res && res.length > 0) {
    // If the code is an id for a Customer Asset in the db, open the Customer Asset form


    var entity = new MobileCRM.FetchXml.Entity("msdyn_customerasset");
    entity.addAttribute("msdyn_customerassetid");
    entity.addAttribute("sie_barcode");

    entity.filter = new MobileCRM.FetchXml.Filter();
    entity.filter.where("sie_barcode", "eq", res [0]);

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

    fetch.execute("Array", function (result) {
    if (typeof (result) != "undefined" && result.length > 0) {
    var productid;
    for (var i in result) {
    var results = result[i];
    productid = results[0];
    }
    MobileCRM.DynamicEntity.loadById(FS.Schema.CustomerAsset.name, productid, function (customerAsset) {
    MobileCRM.UI.FormManager.showEditDialog(FS.Schema.CustomerAsset.name, customerAsset.id, null);
    }, function (error) {
    MobileCRM.bridge.alert(FS.ScanCustomerAsset.localization.get("Alert.BadBarcode"));
    });
    }
    }, function (error) {
    MobileCRM.bridge.alert("An Error Has occurred " + error);
    });


    }
    else if (FS.ScanCustomerAsset.localization) {
    MobileCRM.bridge.alert(FS.ScanCustomerAsset.localization.get("Alert.NoBarcode"));
    }
    else {
    MobileCRM.bridge.alert("No barcode");
    }
    }, MobileCRM.bridge.alert);
    },

    storeLocalization: function (localization) {
    FS.ScanCustomerAsset.localization = localization;
    document.getElementById(FS.ScanCustomerAsset.scanCustomerAssetButtonId).value = FS.ScanCustomerAsset.localization.get("Cmd.ScanCustomerAsset");
    }
    };

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 Complete!

🔔 Be sure to subscribe to the new forums you are interested in to stay up to date! 🔔

Dynamics 365 Community Platform update – Oct 28

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

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,902 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,302 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans