Yvonne
12/09/2024, 5:03 AMbattk
12/09/2024, 8:56 AMbattk
12/09/2024, 8:57 AMbattk
12/09/2024, 8:58 AMlocation.addressee
indicates that the saved search column addressee
is from the location
joinbattk
12/09/2024, 9:00 AMbattk
12/09/2024, 9:01 AMbattk
12/09/2024, 9:02 AMbattk
12/09/2024, 9:03 AMbattk
12/09/2024, 9:04 AMbattk
12/09/2024, 9:07 AMYvonne
12/09/2024, 10:16 PMbattk
12/09/2024, 10:17 PMYvonne
12/09/2024, 10:18 PMYvonne
12/09/2024, 10:23 PMYvonne
12/09/2024, 10:23 PM//#region Line items
var numLines = loadedIF.getLineCount({
sublistId: 'item',
});
log.debug({
title: 'Number of line items',
details: numLines,
});
//loop through the number of line in IF
var items = [];
for (var i = 0; i < numLines; i++) {
var itemInternalID = loadedIF.getSublistValue({
sublistId: 'item',
fieldId: 'item',
line: i,
});
var itemType = loadedIF.getSublistValue({
sublistId: 'item',
fieldId: 'itemtype',
line: i,
});
var isKit = itemType.toLowerCase() === 'kit';
var isInventory = itemType.toLowerCase() === 'invtpart';
log.debug({
title: 'Item Type',
details: itemType,
});
var itemObj = null;
if (isKit) {
//load the item using the internal id
itemObj = record.load({
type: record.Type.KIT_ITEM,
id: itemInternalID,
});
} else if (isInventory) {
//load the item using the internal id
itemObj = record.load({
type: record.Type.INVENTORY_ITEM,
id: itemInternalID,
});
}
if (itemObj) {
log.debug({
title: 'Item found',
details: 'Yes',
});
var item_reference = null;
var item_description = null;
var item_quantity = null;
var item_cartons = null;
var item_width = null;
var item_length = null;
var item_height = null;
var item_weight = null;
var item_lineID = null;
var from_name = null;
var from_phone = null;
var from_address1 = null;
var from_address2 = null;
var from_suburb = null;
var from_state = null;
var from_postcode = null;
// Retrieve the location ID from each line item
var locationId = loadedIF.getSublistValue({
sublistId: 'item',
fieldId: 'location',
line: i,
});
// Load and process location details if needed
if (locationId) {
var locationRecord = record.load({
type: record.Type.LOCATION,
id: locationId,
});
// Access the address subrecord
var mainAddressSubrecord = locationRecord.getSubrecord({
fieldId: 'mainaddress',
});
// Retrieve address fields
from_name = mainAddressSubrecord.getValue({ fieldId: 'addressee' });
from_phone = mainAddressSubrecord.getValue({ fieldId: 'phone' });
from_address1 = mainAddressSubrecord.getValue({ fieldId: 'addr1' });
from_address2 = mainAddressSubrecord.getValue({ fieldId: 'addr2' });
from_suburb = mainAddressSubrecord.getValue({ fieldId: 'city' });
from_state = mainAddressSubrecord.getValue({ fieldId: 'state' });
from_postcode = mainAddressSubrecord.getValue({ fieldId: 'zip' });
}
var item = {
from_name: from_name,
from_phone: from_phone,
from_address1: from_address1,
from_address2: from_address2,
from_suburb: from_suburb,
from_state: from_state,
from_postcode: from_postcode,
};
items.push(item);
} else {
log.debug({
title: 'Item found',
details: 'No',
});
}
}
log.debug({
title: 'Items',
details: JSON.stringify(items),
});
//#endregion
Yvonne
12/09/2024, 10:24 PMYvonne
12/09/2024, 10:24 PMYvonne
12/09/2024, 10:26 PMbattk
12/09/2024, 10:33 PMbattk
12/09/2024, 10:33 PMYvonne
12/09/2024, 10:50 PMYvonne
12/10/2024, 12:22 AMYvonne
12/10/2024, 12:42 AM