Ok so I am working on a new custom extension for M...
# suitecommerce
e
Ok so I am working on a new custom extension for MyAccount that will allow for managing of contacts for Company Type Customer Records. We also allow the contacts to login to the MyAccount portal for the Parent account as well. One feature I am working on is allowing the Account Admin to resend a login or "forgot email" password to its contacts in the account. Digging around SC, I know we have a function called "sendPasswordRetrievalEmail2()" that is part of the 'SC.Models.Init' library. I can not for the life of me get this model included in my custom extension. The only luck I have had was adding it to the older SuiteScript backend models. Which I guess this leads me to 2 questions: 1. If the SC.Model.Init is a server side only library, has it not been migrated to a component or other model for SS2 yet? 2. If the only way to access via SuiteScript 1 extension models, what is the best way to incorporate a "hybrid" approach to both SS1 and SS2 backend models and services? I have also tried within SS2 models to create my own version of this functionality with a password reset token, however I have been hitting a wall trying to update the customer record password fields (password and password2) as well. NS keeps returning an error that password don't match even though hard coded testing is the same string variable. Any ideas or thoughts on the best way to approach this problem?
s
SC.Models.Init is a wrapper for the commerce API, which is a SuiteScript 1.0 API. There is no SS 2.0 equivalent. Someone with more 'real life' experience of doing this sort of thing could probably advise better than I can, but I'm pretty sure you can write a SuiteScript 1.0 service that handles that API call, and then call that using your SuiteScript 2.0 script. In other words, I think you need to break that particular part out.
e
Thanks for responding @Steve Goldberg. My reading of various documentation points has told me the same thing about the CommerceAPI wrapper. And I think you also just confirmed what I thought I had to do, and that is to break it out into a SS1 service. I just didn't want it to be its own extension or anything like that. Documentation on creating SS1 services these days seem to be limited. The only article I can find are yours in regards to some demos on "Add a Button to Remove All Items in the Cart" and "Expose Custom Field Data to the Frontend"
s
Well you could use the service controller module to speed things up
I don't think you need a separate extension; the service.ss file can just be called like you would a REST endpoint
e
That was the current direction I was heading in. Figured I would ask the channel before I go down another rabbit hole
The model points to the URL location of the service
The service is told how to handle requests
But hey, if you really want, you could just construct an XHR to call the service file
e
Trying to build this new functionality "by the book" as much as possible 😉 😂
s
netsuite halo
e
facepalm + 🤪 = netsuite
@Steve Goldberg, just a quick followup to the sample GIT repos you provided. I noticed both are build on 2017 tools. Correct me if I am wrong, but in ExtensionDev tools 2020.2+, the ns.package.json has been replaced by the manifest.json and services are now an "asset"
Never mind. Got it working.