In a user event beforeLoad, i need to add a field ...
# ask-stanley-ai
p
In a user event beforeLoad, i need to add a field on a customer record using form.addField, but I want it in the primary information section in the "main" container. Is that possible?
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** Yes, it is possible to add a field to the "primary information" section in the "main" container of a customer record using the
form.addField
method in a user event beforeLoad script. However, you cannot directly control the position of the field within the section. By default, the new field will be added at the end of the section. Here is a sample code snippet:
Copy code
javascript
function beforeLoad(context) {
    if (context.type !== context.UserEventType.CREATE)
        return;

    var form = context.form;
    var field = form.addField({
        id: 'custpage_myfield',
        type: serverWidget.FieldType.TEXT,
        label: 'My Field',
        container: 'main'
    });
}
In this code,
container: 'main'
specifies that the field should be added to the "main" container. The new field will be added at the end of the existing fields in the "main" container. Please note that this code is for illustrative purposes only and may need to be adjusted to fit your specific needs.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829848766
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.829533517
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.823213041
Please provide your feedback on this answer.