Hello, I want to ask how to get field from other m...
# suitescript
m
Hello, I want to ask how to get field from other menu? I want to get the item rate from Purchase Order and insert it in my custom field at Vendor Prepayment
I can get the item's display name using validation in transaction body field but can't get the rate value.
Copy code
/**
 *@NApiVersion 2.1
 *@NScriptType UserEventScript
 */
define(["N/record"], function (record) {
	function beforeSubmit(context) {
		if (context.type !== context.UserEventType.CREATE) return;
		var purchaseRecord = context.newRecord;
		var rate = purchaseRecord.getSublistValue({
			sublistId: 'item',
			fieldId: 'rate',
			line: 0
		});

		purchaseRecord.setValue({ fieldId: "custbody35", value: rate });
	}
	return {
		beforeSubmit: beforeSubmit,
	};
});
r
I'm not sure about the issue you're having, but I would consider using descriptive fieldIds (Edit -> Change ID on the custom field). I would also strongly recommend not filtering to the create User Event Type until you are nearly finished with testing, unless you are doing your testing programmatically.
It's a lot easier to perform testing using edit and save than creating records over and over.
Have you checked the value and type of the item rate?
m
I use create User Event Type because I test it from "Enter Prepayment" button.
As your suggestion, I have change my custom field's id