Hi guys, Can we extend a backend model in an exten...
# suitecommerce
t
Hi guys, Can we extend a backend model in an extension? For example, if I wanna make some changes to register method of Account Model (backend), is there a way to do that in extension?
s
As long as it is in SuiteScript 1.0, which I believe it still is even in the current version, then you just extend it like you normally would. The only thing I would say is that this kind of customisation is risky and it may break when the code is upgraded
👍 1
f
As Steve mentioned, exporting modules that are not part of the extensibility layer is a risk. It could break in the future.
t
Yes, I agree with that but there has to be a way to customize backend models. What if we want to introduce a moderated signup feature where customers shouldn’t be able to login as soon as they signup until there account is approved by the administration in NetSuite? It’s one of the most demanded feature specially by B2B customers. The only way I believe we have right now is to build our own signup form.
f
If you are not going to use the extensibility layer you could try the sane but with the backend events which are more performant
The way more “extensibilty layer friendly” would be to use the frontend afterRegister event from frontend to call a service that cretes a custom record to save the “registers that are pending approval”. Then on beforeLogin (frontend) check if it was approved or not. If it was not, then cancel login through an exception or a rejected promise. Once approved you should change the custom record status or even delete it.
t
No it is not doable this way. As soon as someone registers on the web store, the system login them from the server and even if we return a reject promise afterRegister, they are already logged in from the server and as soon as they navigate to another page, they will be able to shop just like any other user.
f
Yes, I know but for that you have the commer api, you could just log them out using nlapiGetWebContainer().getShoppingSession().logout()