I have a suitelet call from my myAccount ssp in NS...
# suitecommerce
a
I have a suitelet call from my myAccount ssp in NS which currently is set up available without login and I am having a problem. when the suitelet call is triggered when the logged in user / customer center session navigates to the myAccount area, the suitelet is returning a value of -4 ("System") which nlapiGetUser() is called. The goal is to get the internal ID of the customer logged in so I can retrieve customer record field values and return it in the response object from the suitelet call in SCA myAccount.
e
You need to pass the customer internal id to your suitelet as a parameter. You can use the extensibility API or the profile model to get it.
w
In this case, your Suitelet does not share the same session as your Website, you need to pass the customer internal id.
s
Just to add: this is one of the benefits of using the commerce API and running things within the context of the web store's SuiteScript, you get immediate access to this information. Oh, and just be careful about passing in the user ID -- make sure it is not possible to manipulate this value to get access to data or actions beyond the logged-in users data/actions.
a
Thanks for the feedback. Just to confirm, the problem is not that I have the suitelet setup as available without login right? if the suitelet is configured as available without login and the SCA context has a valid logged in session I should not have a problem right? here is a sample of the code:
(from the SCA side)
would be very grateful to receive some feedback on how I should change the suiteletrequest
w
I think just using the external URL return by your nlapiResolveURL in your nlapiRequestURL without doing the String.Replace should work, try that and see if it works.
as Steve mentioned, you might want to check the native commerce API if you just want to return custom customer fields (assuming main fields), I think it is the safest route without doing all this extra Suitelet calls. Just make sure to apply the field on WebSite.
a
I got it working, thank you everyone for the input! the issue resided in how the suitelet was structured