Hi All, Can any one let me know if the user event...
# suitescript
z
Hi All, Can any one let me know if the user event is triggered when the inbound shipment status is changed from "To Be Shipped" to "In Transit" from a button(Mark in Transit)? Thanks
t
have you tried adding logs?
n
@Zeeshan I don't see it listed in help but as Tyn mentioned you could log the UserEventType: For the related help: https://<youracount>.app.netsuite.com/app/help/helpcenter.nl?fid=section_4407992596.html If you find there is an appropriate type maybe post back here your findings ๐Ÿ™‚
t
NO
I had to use a scheduled script to perform what I wanted to back then
n
I imagine you could use a UE script to check on edit if that status had changed to "In Transit" comparing the oldRecord / NewRecord value beforeSubmit...
z
I verified UE, event never triggers on the mentioned action.
there is also a limitation on the saved search that modified date is neither available on filters nor columns.
and the last resort would be to execute the search using Analytics. Last Modified Date available here ๐Ÿ™‚
Thanks @Tyn Guardian, @NElliott, @tuli for the quick responses. I believe that my last message would be helpful for everyone.
n
@Zeeshan does the inbound shipment not have a status you can check as I proposed?
@Zeeshan You should be able to check this field for this value: fieldId: 'shipmentstatus' , value: 'inTransit' so I'd do something like :
Copy code
let newRecord = context.newRecord;
let oldRecord = context.oldRecord;
let oldStatus = oldRecord.getValue({fieldId:'shipmentstatus'})||'';
let newStatus = newRecord.getValue({fieldId:'shipmentstatus'})||'';
if(oldStatus !=='inTransit' && newStatus ==='inTransit'){
// your logic here
}
t
@NElliott The user event is not triggered while marking it inTransit. Now who will come to Inbound shipment and edit and save that. and even someone will do it doesnโ€™t makes sense. That was pretty weird situation back then, but Iโ€™ll look up to search using analytics.
I absolutely agree with you, I talked it with my team back then and they proposed the same solution you did, and seems obvious, I might have proposed the same, but then I went in to weeds to know the actual situation there ๐Ÿ˜„
n
Right, OK, I thought you were saying you couldn't establish the trigger type when it moved to In Transit, not that a UE was not triggered at all ๐Ÿคทโ€โ™‚๏ธ (just looked back at your original question and appreciate that's what you asked)
z
Thanks for the clarification @tuli to @NElliott :)
We all the need to play with analytics feature inside SuiteScript 2.x.
t
Once done, please share back ๐Ÿ˜„
๐Ÿ„ 1
z
const getModifiedInboundShipments = (lastSyncTime = '') => {
if (lastSyncTime === '') {
throw {
name: 'LAST_SYNC_TIME_IS_BLANK',
message: 'lastSyncTime can not be blank.'
};
}
const inboundShipQuery = nsQuery.create({
type: nsQuery.Type.INBOUND_SHIPMENT
});
const firstCondition = inboundShipQuery.createCondition({
fieldId: 'lastmodifieddate',
operator: nsQuery.Operator.AFTER,
`values: `${lastSyncTime}``
});
const secondCondition = inboundShipQuery.createCondition({
fieldId: 'shipmentstatus',
operator: nsQuery.Operator.ANY_OF,
values: ['inTransit']
});
inboundShipQuery.condition = inboundShipQuery.and(
firstCondition,
secondCondition);
inboundShipQuery.columns = [
inboundShipQuery.createColumn({
fieldId: 'lastmodifieddate',
alias: 'lastModifiedDate'
}),
inboundShipQuery.createColumn({
`formula:
TO_CHAR({lastmodifieddate}, 'DD-Mon-YYYY HH12:MI:SS AM')
,`
type: nsQuery.ReturnType.STRING,
alias: 'lastModifiedDateStr'
}),
inboundShipQuery.createColumn({
fieldId: 'shipmentnumber',
alias: 'shipmentNumber'
}),
inboundShipQuery.createColumn({
fieldId: 'id',
alias: 'internalId'
})
];
inboundShipQuery.sort = [
inboundShipQuery.createSort({
column: inboundShipQuery.columns[0]
})
];
// returns max 5K records
const resultSet = inboundShipQuery.run();
const mappedResultSet = resultSet.asMappedResults();
return mappedResultSet;
};
Cheers ๐Ÿ˜‰
FYI: @Tyn Guardian @NElliott @tuli
keanu thanks 1