Retrieving currently logged in user's title/salutation fails - netsuite

In NetSuite SuiteCommerce Advanced I am attempting to get the currently logged in users title (Mr, Mrs, etc.).
I am using the Commerce API and the function Customer::getFieldValues(). I am retrieving the column/field name salutation. When I execute this function it returns an empty object when it should return the users title/salutation. Note: I have confirmed the user has a title/salutation set as 'Mr'.
Any advice why SCA is not returning the user's title? This is sooo annoying of NS!
*Modules\MyOverrides\ProfileOverrides#1.0.0\SuiteScript\Profile.Model.js:
define('Profile.Model',['SC.Model', 'underscore', 'Utils'], function (SCModel, _, Utils)
{
'use strict';
return SCModel.extend({
name: 'Profile'
, get: function ()
{
//You can get the profile information only if you are logged in.
if (this.isLoggedIn && this.isSecure)
{
// Retrieve the currently logged in users saluation (eg Sir, Mr, Mrs, etc.)
// Why on earth does NS not return this!!!
var profile = customer.getFieldValues(['salutation']);
console.log("PROFILE", profile); // outputs "PROFILE {}"
...
*Edit: I incorrectly stated the file was
Modules\MyOverrides\AccountOverrides#1.0.0\SuiteScript\Account.Model.js: when it is actually Modules\MyOverrides\ProfileOverrides#1.0.0\SuiteScript\Profile.Model.js.

Related

User profile enrichment in AZUREAD

I have a question regarding user profile enrichment.
How can I enrich a user profile with extra information such as id-number, personal telephone, and any other information available in my office356 platform?
I have an Angular SPA in which the user must log in and subsequently do some actions, but I do require to get the info mentioned before in order to do so.
I have code like the showed below. I've searched into Azure's documentation but found nothing yet.
const GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/me';
getProfile() {
this.http.get(GRAPH_ENDPOINT)
.subscribe(profile => {
this.profile = profile;
console.log(profile)
});
}
getProfilePhoto() {
this.http.get(GRAPH_ENDPOINT+'/photo/$value').subscribe(
photo => {
this.photo = photo;
console.log(this.photo);
});
}
Any help or tip to help this poor fellow programmer?
Thanks!
Please check this if query for id or mobile number etc can be worked for the similar code, if am not understating wrong:
As 'https://graph.microsoft.com/v1.0/me gives complete profile details just like code provided
const GRAPH_ENDPOINT = 'https://graph.microsoft.com/v1.0/me';
getProfile() {
this.http.get(GRAPH_ENDPOINT)
.subscribe(profile => {
this.profile = profile;
console.log(profile)
});
}
same in microsoft graph api :
Just like that we can query for id, mobilephone number, and other details
By filtering using select query
See References for more query parameters: Get a user-Microsoft Graph v1.0 | Microsoft Docs -REFERENCE , Use query parameters
So to get mobilenumber in graph https://graph.microsoft.com/v1.0/me?$select=mobilePhone is used, same can be modified for code some thing like below
Example:
getMobileNumber() {
this.http.get(GRAPH_ENDPOINT+'?$select=mobilePhone ').subscribe(
mobilePhone => {
this. mobilePhone = mobilePhone;
console.log( this. mobilePhone);
});
}
Just like from graph
So to get id in graph https://graph.microsoft.com/v1.0/me?$select=id ,modify your code which uses this request.
Example:
getId(){
this.http.get(GRAPH_ENDPOINT+'?$select=id ').subscribe(
Id=> {
this. Id= Id;
console.log( this. Id);
});
}
You can also make use of graph client
References:
Build Angular single-page apps with Microsoft Graph - Microsoft
Graph | Microsoft Docs
azure - Obtaining Profile Photo from MS Graph API to Angular app -
Stack Overflow from >> So reference
create-requests-typescript

nlapiSendEmail returns SSS_AUTHOR_MUST_BE_EMPLOYEE from correct employee id (on Sandbox)

in a Sandbox environment nlapiSendEmail (defined inside a suitelet) returns SSS_AUTHOR_MUST_BE_EMPLOYEE even when the sender id is correct
My distribution is Kilimanjaro, with SuiteScript 1.0. I have an administrator role, when calling nlapiSenEmail() directly from the backend model with my employee id, the email was sent to my employee profile, but not to the specified email, which is really a company distribution list. Even when I did not specify the logged customer email, a copy was sent to the logged customer email, a gmail account. The backend model operates only for the MyAccount application. It's worth noting that in this scenario nlapiSendEmail() return value was undefined. In my experience, Netsuite is really ambiguous in its behavior returning values or just functioning in an expected way, due to the "execution context". So, with the same data I put my call inside a suitelet, and now I am having the return SSS_AUTHOR_MUST_BE_EMPLOYEE.
function sendEmailWithAPI(request, response)
{
var senderId = request.getParameter('senderId');
var to = request.getParameter('emailTo');
var subject = request.getParameter('subject');
var body = request.getParameter('body');
var cc = request.getParameter('emailCC');
var result = {success:false, errorInfo:''};
try
{
var sendingResult = nlapiSendEmail(senderId, to, subject, body, cc);
result.success = true;
}
catch (errorOnMailSending)
{
result.returnValue = sendingResult;
result.errorInfo = errorOnMailSending.details;
}
response.write(JSON.stringify(result));
}
What is the record type of the senderId? NetSuite only accepts Employee records as sender of script generated emails. Also in Sandbox accounts, the emails are re-routed to the logged in user, specific list, or not at all. This is actually based on the Company preference in your Sandbox account. The reason for this is Sandbox is usually used for testing and you don't want to send test emails to actual customers.
In the end the "problem" was that I was just working in the Sandbox, as I prepared a snippet to test email sending in production everything went right. In the sandbox you can still send emails specifying a list at the subtab "Email options"
with the option "SEND EMAIL TO (SEPARATE ADDRESSES WITH COMMAS)"
this is located at Setup > Company > Email Preferences.

How can i check my input after each iteration on Luis?

if (!meeting.location) {
builder.Prompts.text(session, 'where is the location');
} else {
next();
}
This is a part of my node.js code where my bot tries to identify the location in the first message , if he doesn't find it he takes as location any value the user gives, might be as random as "83748yhgsdh".
My question is how can i allow my system to check the user input at each step and only take reasonable ones.
You can probably manually call the LUIS recognizer
e.g:
var recognizer = new builder.LuisRecognizer(model);
recognizer.recognize(
"hello",
model,
function (err, intents, entities) {
console.log(intents);
}
)

How to add additional dialog in bot framework

How can I have 2 conversations going concurrently? I'm currently using TextBot and LuisDialog to build a bot. I start off by having a conversation with the user to obtain data. Then while doing some processing in a different method, I discover that I need additional information from the user. How can I create a new conversation with the user just to get that additional information? I have some code below that attempts to show what I want to do. Thanks for your suggestions.
File 1: foo.js
var dialog = new builder.LuisDialog(model);
var sonnyBot = new builder.TextBot();
sonnyBot.add('/', dialog);
dialog.on('intent_1', [
function(session, args, next) {
name = builder.Prompts.text(session,"What is your name?");
},
function(session, result) {
session.dialogData.name= results.response;
getFamilyTree(session.dialogData.name);
}
]);
File 2: getFamilyTree.js
function getFamilyTree(name) {
find family tree for name
if (need place of birth) {
begin new dialog
prompt user place of birth
get place of birth from user
end dialog
}
finish getting the family tree
}
i guess you could pass session object and then use that object to start a new dialog .
Edit 1
can't you use some thing like
session.beginDialog('/getFamilyTree',{name:result.response});
and then you can access name like
args.name
inside 'getFamilyTree' dialog
I posted the same question on GitHub and received the answer from Steven Ickman, who is involved in the development of the node.js SDK. The link to the answer is https://github.com/Microsoft/BotBuilder/issues/394#issuecomment-223127365

Couchdb and Sofa Help

I'm new to Couchdb just a few week back I git clone the couchdb app called sofa [what and app] . Over the week It was going great but suddenly today I stumble upon something.
Here what I meant
when I browse the Sofa app and try to create a Post without the title
it prompt with and alert box "The document could not be saved: The database could not be created, the file already exists." which was weird as looking at the source I found that the require (in validate_doc_update.js return its custom json error) something like in this format {"forbidden" : message }) with forbidden as key
v.forbidden = function(message) {
throw({forbidden : message})
};
v.require = function() {
for (var i=0; i < arguments.length; i++) {
var field = arguments[i];
message = "The '"+field+"' field is required.";
if (typeof newDoc[field] == "undefined") v.forbidden(message);
};
};
in validate_doc_update.js
if (newDoc.type == 'post') {
if (!v.isAuthor()) {
v.unauthorized("Only authors may edit posts.");
}
v.require("created_at", "author", "body", "format", "title");
inspecting the response state that the json returned was found to be different from the json had it would have been return by the above require function in validate_doc_update.js
here is the json
{"error":"file_exists","reason":"The database could not be created, the file already exists."}
This make be believe that the validation in validation_doc_update.js only execute during updating of document
to Prove this point I try to update a document without the title, expecting that it would return the error but surprisingly the document just got saved
so Here are my Question regarding all the Point I mention above
Does validate_doc_update.js "validate" work only during updation of document
if YES
then
how can I manage to succeed in updating a post without the error [Weird bypassing the Validation Completely] . + How can execute validation on create of a document
if NO
then
What is the Error {"error":"file_exists","reason":"The database could not be created, the file already exists."} that is prevent a document to be saved
Can anyone please share light on all the questions listed here
Yes, the validate_doc_update functions are run only when updating documents (include creation and deletion).
The function you show here will allow a document without a title as long as its type is not "post". If you could include the actual request you attempted, I could confirm it.
Finally, the ""The database could not be created" is because you are attempting to create the database (by doing PUT /dbname/ instead of PUT /dbname/docid, I would guess) when it already exists. Again, if you would include the actual request, I could confirm that too.

Resources