Hello, does anyone know if there's a reason why `g...
# suitescript
l
Hello, does anyone know if there's a reason why
getLineCount()
returns 0 for User Event in view mode? I'm trying to pull lines of sublist that consists of custom records. I get correct amount of sublist items in edit mode, also I still can pull list of sublists of parent record in view mode anyway.
m
I've been frustrated by that in the past as well and have yet to figure out a reason for it. My workaround is to load the record in view (using N/Record) to get line counts but that feels like an otherwise unnecessary database hit compared to create/edit modes (with all of the related performance impacts, etc.).
I'd be very interested to hear if anyone has any better workaround suggestions.
a
When you say view mode I assume you mean
beforeLoad
entry point?
m
beforeLoad
is my use case, yes. An example of why I've wanted to get line counts in `beforeLoad`/`view` is to disable buttons based on whether or not a particular sublist has any entries in it.
a
@MTNathan I understand but according to the
beforeLoad
help: • Data cannot be manipulated for records that are loaded in beforeLoad scripts. If you attempt to update a record loaded in beforeLoad, the logic is ignored.
Another way to deal with it could be a search instead of loading the record.
m
I'm not trying to update anything in the sublist though (or elsewhere on the record), just trying to read data from it (the same way you might use the value in a field in
beforeLoad
to adjust the form, which is definitely supported). A search is a good alternate suggestion, though I don't know if that's better for performance than a record load.
l
@alien4u correct, I meant
beforeLoad
entry point. Even if record is loaded in read-only mode, personally I see no reason why that data could not be available. @MTNathan was trying to do the same thing as it turns out
a
@MTNathan There is no significant difference from a Search to a record load, in some cases a search is faster than loading a record.
m
@alien4u That's what I figured, thanks for confirming. I guess at that point it would come down to whether you need info about a single sublist or multiple - loading the record gets all of the sublists so that could avoid multiple searches, but if you only need one then maybe searching is preferable.
136 Views