Hello Sublist has an column field which is SELECT ...
# suitescript
b
Hello Sublist has an column field which is SELECT type. I have another field which is also SELECT type and based on that value, that sublist field should be changed. Is there any method to change that sublist column field options in Client script please?
n
use fieldChanged in a client script.
the script context has sublistId and fieldId so you can definitively apply logic.
b
@NElliott I need to change sublist field options Yes I know I should do that in fieldChanged But not sure how to do that
Copy code
let contractField = form.getSublistField({            
            sublistId: 'custpage_contract_lines',
            fieldId: 'custcol_line_contract_line',
            line: 0
        });

        contractField.removeSelectOption({value : null});

        contractField.insertSelectOption({
            value : '- None - ',
            text : 'Please Select'
        });
n
you said "it should be changed" you did not say the "content should be changed" The short answer to that is, "no".
b
you mean we can't change sublist field options?
👍🏻 1
n
Content of a select field is "generally" static. A way around it is to add a custom field dynamically in a user event before load and build the select options on the fly. However that's not possible to the best of my knowledge on a sublist select field.
The alternative would be to have every possible option in the second select list and disable it to stop a user altering it if the value of the first is the control.
b
I have one select field and one sublist field
so let's say we have a SELECT field to show Customers
and we have sublist to show transactions
so sublist column should only have transactions related to that customer, not all transactions
could you tell me how to do that please?
b
Field.insertSelectOption is what you want
b
but it's sublist field @battk
n
I'd suggest your sublist should be based on a search and have that filtered based on the select value
b
however that particular option has to deal with the annoyance of line being mandatory in ss2
n
He's looking to filter his sublist is what I'm reading now...
hmm or maybe not
b
In a suitelet custom sublist
b
unless he plans on making it a standard custom field instead of a field added via script, a search is not option
b
@battk I tried it before but it shows me this error
SSS_INVALID_SUBLIST_OPERATION
b
we are now at the annoyance part that i mentioned
im guessing you are trying to do this for your very first line
b
yes
b
which means that there are no existing lines, which means there is no line at index 0
you have 3 basic options to work around that line
the first is to use ss1, the second is to temporarily have 1 line so that you can get and store the field for later use, or trick the line validation
though i dont think the ss1 documentation in actually online anymore, you will have to look into the ss1 pdf they offer now
b
Thank you @battk
@battk I tried pageInit method but it still shows me same error in PageInit
SSS_INVALID_SUBLIST_OPERATION
I created that sublist in INLINEEDITOR mode if that helps you
It throws me error in PageInit
b
you never committed the line
so there still isnt a line 0
b
Thank you
It works now
Actually it throws me another error which seems like different issue "SSS_INVALID_UI_OBJECT_TYPE" when I try to
removeSelectOption
Before that I print the field and it shows the field object so I think they are different issues
Any idea @battk please? It is certainly SELECT column field
when I run console.log() for that field, it returns Field class instance with all those functions like insertSelectOption and removeSelectOption exists
b
this is probably because you gave a terrible field id
use custpage as the prefix
custcol is only going to confuse
b
I see
Thank you for your help
WOW it works like charm. I really appreciate your help. @battk