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.
It worked with me. Thank you.
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.
When trying to import the single Offline HTML file, the other Offline HTML file are deleted. So, how to import the file?
Why did you have to import the project? Should be enough to just modify the single Offline HTML file.
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??
You can simply download the Woodford project from aka.ms/fsmobile-project and get the JS file as explained above.
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.
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");
}
};
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,902 Super User 2024 Season 2
Martin Dráb 229,302 Most Valuable Professional
nmaenpaa 101,156