hey guys, because im a noob, how do I require a fi...
# suitescript
l
hey guys, because im a noob, how do I require a field at the line level to be filled if another field is filled at the line level. See below - this is the best I can come up with so far. I want this to occur when the line is added.
Copy code
/**
 *@NApiVersion 2.0
 *@NScriptType ClientScript
 */

require(['N/currentRecord'], function (currentRecord) {



if //if this field is not null, then
  custcol_projectfield1 <> null

  //require this field below to have a value
  custcol_projectfieldtask1
}
s
First thing you need to ask yourself with client side validation is when do I want this check to happen? When the line is added or when the record is saved, etc.
l
Line added 🙂 Thanks for that!
s
You have a couple of choices, definitely check the client script entry points, sublistChanged and validateLine are your most likely candidates. Sublists are little different from regular fields in that you cannot make a column required on a sublist without making it required for every line. So you most likely either want to check if they filled out both on validateLine and return false if they didnt (with some alert). Or you can check sublistChanged after they submit the line and warn them something is wrong, but accept the line change. Doing the second one would probably also require validation on save to verify they fixed the problem you warned them about.
l
@Sandii - OMG, Thank you!
Off I go to learn something new
Copy code
if(custcol_projectfield1==null){
true;
} else{
  alert
}
I thought i could have done something like the above and be done….
s
Just remember when doing any validation client side, try to have it to do as little as possible for best user experience, and on validation entry points, always
return true/false
💯 1