Is there a way to prevent users from choosing a pa...
# general
m
Is there a way to prevent users from choosing a parent location on all transactions (one that doesn't have a parent)?
v
@Marawan مَرَوَان You can achieve this using either a Workflow or SuiteScript by adding a condition to check whether the selected Location has a parent or not depend on your exact requirement. If the Parent Location is empty, then it means the selected Location is a top-level/parent Location, so we can prevent the user from selecting it or saving the transaction. We can handle this in two ways: • Using a Client Script to validate it as soon as the user selects the Location. • Using a User Event Script to prevent the user from saving the transaction if a parent Location is selected. Personally, I’d suggest going with SuiteScript, as it gives us more flexibility, especially if the Location is being selected at the line level. I don’t think Workflow would handle the line-level validation as smoothly due to some system limitations.
j
In case you have stand-alone locations, the validation should also check that the selected location does not have child locations
m
Got it, thanks everyone 🙏 🤍
c
I'd recommend doing both CS and UE validation. With the CS depending on your environment you could readily temporarily cache all of the child location ids in the local storage for a snappier experience. UE to reject the invalid transaction (ex: a bad integration that sidesteps cs processing)
➕ 1
☕ 1
m
It is what I ended up doing. But without caching, it would be a good enhancement, although I am always reluctant to use caching, it is tricky. Maybe in NS it is not that hard, I don't know.
j
the trick to this used to be switch on inline editing in the locations list, and mark all the parents as inactive from the list and click submit (don't tick inactive in the record itself, or else the inactivity propagates down the tree). End result is parents are unselectable but you can still roll them up in reports.
m
Even with the inline editing feature enabled... there is still no inline editing in the locations list. @Jon Kears
j
that's so strange, I have the ability to do it on my screen
m
Aha, I got what you mean now. I thought you were talking about the edit checkbox. But wow, I didn't know this trick. Thanks!!!
🙌 1