Using SiteBuilder Kilimanjaro, is there a way to g...
# suitecommerce
c
Using SiteBuilder Kilimanjaro, is there a way to get the current users price level name? At the moment profile.get('priceLevel') returns the price level internalid only. Looking at the profile model, it calls this from ModelsInit.session.getShopperPriceLevel().internalid. getShopperPriceLevel itself returns the internalid only.
s
Price level is a scriptable field (https://system.netsuite.com/help/helpcenter/en_US/srbrowser/Browser2024_1/script/record/pricelevel.html) so it should be relatively easy to ask NetSuite to look up the price level by ID and return the name, and then return that name as property of the profile object.
e
@Steve Goldberg do you know if we can do the same to expose a value on the
UserProfile
component? I have not been able to do it and I think it is not possible by design.
s
Well, you would have to change how the UserProfile component generates its properties
If you look at the code, you can see that it defines the properties it's going to return
Of course, that advice only applies to SCA. If you're talking about SC, then I wouldn't recommend trying to modify a component in the extensibility layer
e
Oh, this is interesting! Can you point me on the right direction? I'm not sure where it defines the properties to add a new one.
s
./Commons/Profile/JavaScript/Profile.Component.ts
The
normalize()
function
And then, at the bottom, the
generateComponent()
function
e
I will take a look at that. Thanks @Steve Goldberg. Appreciate it.
c
@Steve Goldberg thanks for getting back to me. So am I looking at the Profile.Model JS or SuiteScript file? I have tried modifying the SS as there is getFieldValues for the customer record, but adding pricelevel to the list does not return it in the profile. I'm a little bit lost here, would appreciate any further help you could provide.
s
You will need to write SuiteScript that loads the record for the price level. If the price level is 5, then I think you can just use nlapiLoadRecord to load record 5, and then return its name. I'm sensing you're not experienced with SuiteScript?
c
I’m good with suitescript, wasn’t sure how to incorporate that with Kilimanjaro.
s
Alright, well, perhaps I'm being naive but something like this:
Copy code
var plrecord = nlapiLoadRecord('pricelevel', <customer price level>);
Would load the price level record? Then just get its name?
If you've already customised your Kilimanjaro source code then you could just put that into the Profile.Model file. Otherwise you could wrap the function.
e
A search, query or lookup would have a better performance instead of loading the record itself. However it does not seem to be exposed on a search but it does on a query
s
Yes, good call. nlapiLookupField should be fine for this
c
Thanks, I was expecting something more complex than that, didn't expect nlapi to work here 🙂 So the next issue is role permissions. As I am now trying to access list, specifically accounting lists I am getting a permission violation. So I go to the customer centre role to add in the accounting list for view, but customer centre's do not allow me to add a new permission. I'm assuming I'll new to set up a brand new role for this to work?
e
c
Perfect, got there in the end. I had to create the custom role, as Kilimanjaro does not come with the Advanced Customer Centre role. Thanks for both your help, much appreciated.
🤝 1
The only small issue I've found is that after a gulp deploy, I have to resave the ss file with the elevated role permission otherwise it fails with a permission error again.
e
Yeah, that is a missing feature that we have discussed some time ago. An option to setup this on the manifest.json or the one use on custom module would be helpful to handle this. So it does not get reset on every deployment. You might need to take note of this details, otherwise in the future it would be a headache.
c
Thanks for confirming, will try to keep these type of changes to a minimum 🙂
e
I would put a comment on the code about what role you should setup on the service on each deployment, the path on the file cabinet would be handy as well.
🙌 1