I'm trying to create a custom select field on line...
# ask-stanley-ai
j
I'm trying to create a custom select field on line items. What I am trying to achieve is source the item Purchase Contract and add them as selections dynamically to the select field. However, I only want the selection to show the Purchase Contract of this line item. But when I use currentRecord.insertSelectionOption, it will add the selection to all line item select field. Is there a way to only add selection to one line item select field?
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue you're facing is due to the fact that SuiteScript treats all fields in a column uniformly. This means that when you use
currentRecord.insertSelectionOption
, it will add the selection to all line item select fields, not just the one you're currently working with. One workaround suggested in the conversations is to use a second field on your custom line record. This field would have all options available for the vendor, and when a line is committed and a value is set in your existing line level vendor field, you would copy the value of the vendor from that field to your basic field of the same type. This way, the value is stored and you don't care what options are now missing for lines which are already committed. Here's a rough idea of how you might implement this: 1. Create a second field on your custom line record. This field should be a list/record vendor field with all options available. 2. In your User Event or Client script, when a line is committed and a value is set in your existing line level vendor field, copy the value of the vendor from that field to your new field. 3. You might need to add some show/hide fields logic to make it look better in the UI. Remember, this is just a workaround and might not be the most elegant solution. It might also be a bit confusing for new users as to why there are two vendor columns, and the one they can edit behaves a bit weirdly. You could address this with documentation or training. ****** 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.829051554
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.828720391
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.817749798
Please provide your feedback on this answer.
Thank you for your feedback