How do I make it appear only '0000' if there is no...
# suitescript
s
How do I make it appear only '0000' if there is no information in these fields? Yes, I make a condition for them. But how do I show these numbers in the system, if there is no information?
Copy code
sublista.addField({
            id: 'sublista_campo4',
            label: 'Referência',
            type: serverWidget.FieldType.TEXT
        });

    sublista.addField({
            id: 'sublista_campo5',
            label: 'Valor',
            type: serverWidget.FieldType.TEXT
        });
r
Have you added the sublist to the form?
s
@reptar Yes, I did. I assume I did this in code.
r
Check out the defaultValue property in the api document.
s
@reptar Sorry for the question, how do I do it? 😅
r
s
Right. Thanks again 😄
👍 1
Hmmm! Hey, can I put this property inside if()?
r
Sure. Var field = sublist.addfield(...); if (condition) {field.defaultValue = x;}
❤️ 1
s
@reptar Thank you again!
@reptar Hey, about kind of event, which one do I use? This form I made will be used by another sector. In this case, the fields will be filled by this other sector. I'm in doubt if I use GET or POST. In fact, I don't know which one I use. Can you help me?
r
Get is generally for gathering and displaying data. Post is for submitting data to the db.
👏 1
Post gets kind of tricky in suitelets. It changes the url from the suitelet url to scriptlet .nl, which has the side effect of having to hit back a hundred times when you're submitting multiple times.
👏 1
If you're just creating a custom record with a sublist, it would probably be easier to do it using SuiteBuilder
👏 1
s
@reptar So, I asked to create the forms in order to study suitescript development. But yes, they would use SuiteBuilder. I was the one who asked me to try to learn how to do it by code. As complicated as it is, I find it interesting to build from code. Just to learn, you know? But thanks for the info.