Reputation: 23
I would like to know how to pre-set the "custom form" when creating an item, based on the "record type", e.g. inventory item, serialised inventory item, lot numbered inventory item, etc.
I have try:
So I would like to know whether there is a way to pre-set the form first based on different item record types??
Many thanks!!
Upvotes: 2
Views: 1802
Reputation: 8902
This is tested and working in my SDN account:
function beforeLoad() {
var formByType = {
"serializedinventoryitem": "33"
};
var recordType = nlapiGetRecordType();
var currentForm = nlapiGetFieldValue("customform");
var desiredForm = formByType[recordType];
if (desiredForm && (currentForm != desiredForm)) {
nlapiSetRedirectURL("RECORD", nlapiGetRecordType(), nlapiGetRecordId(), true, {"cf":desiredForm});
}
}
Just fill out the formByType
object with the keys being the record types and the values being the form each type should map to.
If you leave a specific type out of formByType
, then no redirection is attempted and the preferred form would be used.
Be aware that you will need multiple deployments of this User Event script, one on each of the various item types you need to redirect.
Upvotes: 1