I want to lock field PO Issuer after the Purchase ...
# ask-stanley-ai
i
I want to lock field PO Issuer after the Purchase Order has been created. Right now it is automatically picking up the current user and assigning it as PO Issuer after it has been created.
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the best way to lock the PO Issuer field after the Purchase Order has been created is by using a workflow. You can create a workflow that triggers after record submit when the Purchase Order is created. In this workflow, you can add a state with an action that sets the field 'PO Issuer' to read-only. This will prevent the field from being edited after the Purchase Order has been created. Here is a sample code snippet that you can use as a reference:
Copy code
javascript
var workflow = nlapiCreateRecord('workflow');
workflow.setFieldValue('name', 'Lock PO Issuer');
workflow.setFieldValue('recordtype', 'purchaseorder');

var state = workflow.createSubrecord('workflowstates');
state.setFieldValue('statedefinition', 'Start');

var action = state.createSubrecord('workflowactions');
action.setFieldValue('actiontype', 'fieldchange');
action.setFieldValue('field', 'custbody_po_issuer');
action.setFieldValue('attribute', 'readonly');
action.setFieldValue('value', 'T');

nlapiSubmitRecord(workflow);
Please replace 'custbody_po_issuer' with the actual internal id of your 'PO Issuer' field. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.819579244
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81761539
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.815349042
Please provide your feedback on this answer.