Hey Guys, ln Client script ValidateLine function l...
# suitescript
n
Hey Guys, ln Client script ValidateLine function like we can add condition for sublistId by getting var sublistName = context.sublistId; Can we get sublistField as well like this??
n
Not really. The validateLine function is triggered when the entire line is committed. You would be able to get the value of any field you want from that line, but there isnt a specific field that would be passed to the function. The fieldChanged event does however capture sublistId, line, and fieldId
Here is what is available in the validateLine
b
n
@Nathan L & @battk so there is no way to check the SublistField in validate Line or in validateField?? sublist level field I mean like if sublist level field is this then only do xyz!!??
b
go through the Client Script Entry Points for your entry points to see what you have available
n
You can get a sublist field value yes, what you cannot do is use context.fieldId value on validateLine because no one fieldId would be valid. There's no reason why you cannot, on validateLine, get one or more specific fields and apply logic, you just need to know the id's of the fields you're interested in. If you specifically want logic to apply when a field changes then use the appropriate entry point.
n
I can get sublist field value that is right but what I want to do is run a logic if and only if that sublist field value is changed!!! like this!! can I do like this?
b
honestly your question is a little on the weird side
💯 1
you cannot get the value of the field without actually knowing the field id
and your question is about how to find out the field id
n
im sorry if I was not clear😅
n
You need to understand the difference between the entry points.
n
my question is: as we run logic inside if condition for sublistId var sublistId = context.sublistId; if(sublistId == 'item'){}
Can we run a logic for sublistField
like if(sublistField == item){//logic}
b
as far as i can tell , you arent looking at the documentation close enough to figure out the answser
n
I checked there I can't find anything related to sublistField so I asked!
b
so my recommendation is to do it the hard way and write code that logs the script context of your entry point so you can see what you have access to
n
If you are in fieldChanged you can ascertain the sublistId and the fieldId. There is no such thing as "sublistField" For example if you are interested in "description" on the "item" sublist you would be doing:
if(context.sublistId === "item" && context.fieldId ==="description"){
// your logic here.
}
In the case of validateLine there is no context.fieldId because that's not applicable for validateLine for <reasons already explained>
n
cool, then I think I need to use fieldChange function and write my logic there!! thank guys!!
👍 2
n
of course, in validateLine you can still access line values you just need to know the fieldId's but this entry point is not triggered when a field changes.
n
You either need to use validateField or fieldChanged. validateLine is not what you are looking for.