IntegrationHub OnBefore script not working

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:32 AM
Hi all,
I am using IntegrationHub to take an Excel file and transform the data to the Contract, Asset, and Assets Covered tables.
On the integration, I have a simple OnBefore script where if the Asset Type column on the Excel document is "Workstations" or "Notebooks", set the PO Number to "94904", but it does not work. I've looked at documentation for similar tasks and tried various iterations of this script but can't find a reason why this wouldn't work.
Why might this be?
(function onBefore(source, target, importLog) {
if(source.u_asset_type == "Workstations" || source.u_asset_type == "Notebooks")
source.u_po_number = '94904';
})(source, target, importLog);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 08:48 AM
HI @DylanBlumenberg
can be different reasons but In script you are setting source field instead of target try to use this script
(function onBefore(source, target, importLog) {
if (source.u_asset_type == "Workstations" || source.u_asset_type == "Notebooks") {
target.u_po_number = '94904';
}
})(source, target, importLog);
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 09:08 AM
Hi Yousaf, I switched the script to the one you posted but it isn't affecting the PO number that gets pushed to the record.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 09:23 AM
Ok so there be many reasons its not working please check these
1. Check if this field is not mapped in transform map because if it is it will overwrite the script
try using onAfter with target.update....
2. Make sure there are no whitespaces or case sensitivity issues
Try using .trim() and toLowerCase()
(function onAfter(source, target, importLog) {
var assetType = (source.u_asset_type || ' ').trim().toLowerCase();
if (assetType === "workstations" || assetType === "notebooks") {
target.u_po_number = '94904';
target.update();
}
})(source, target, importLog);
3. Make sure you are using correct field name and it is not read only on the form
4. Check if user has the permission to write on the field
***Mark Correct or Helpful if it helps.***

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2025 09:26 AM
Also add logs in the script to see where it is failing.
target will update the final table not the staging table
***Mark Correct or Helpful if it helps.***