define ( ['N/record', 'N/ui/serverWidget', 'N/runtime','N/https'] ,// Add the callback function.function(record, serverWidget,runtime,https) {
// In the afterSubmit function, begin creating a task record.
function myAfterSubmit(context) {
var tgType = context.type;
if(tgType == 'create' || tgType == 'edit' || tgType == 'copy') {
var saleOrder = context.newRecord;
log.debug({title: 'Record Type ', details: context.newRecord.type });
if (saleOrder.type == "salesorder" )
{
var uniqueKey = saleOrder.id
log.debug("uniquekey",uniqueKey)
}
else
{
log.debug("error",'No data found')
}
}
return {
afterSubmit: myAfterSubmit
};
});
Hello Netsuite experts,
I am looking for solution to access created customer's info with aftersubmit function of userevernt script.
salesorder is working well
Tried "customer" and it's not triggering to the script.
Thanks!
Do You want created customer's internal id in your script? if yes,
here is the code, in after submit for edit mode you need to use oldRecord
otherwise for newly created use newRecord(on create/copy mode and load the record). and deploy it on customer record as well.
function myAfterSubmit(context) {
var tgType = context.type;
if(tgType == 'create' || tgType == 'edit' || tgType == 'copy') {
var rec= context.oldRecord;
log.debug({title: 'Record Type ', details: context.oldRecord.type });
if (rec.type == "customer" )
{
var customerIntId= rec.id
log.debug("customerIntId",customerIntId)
}**strong text**
else
{
log.debug("error",'No data found')
}
}
Related
I'm trying to copy the serial # from inventory detail on a Item Fulfillment line to another field for further processing, for which I'm trying to do a field changed function via Client Script but not able to figure out the field trigger.
This is what I have so far...
function populatePIF(type, name)
{
if(name == 'inventorydetail')
{
nlapiLogExecution('DEBUG', 'TEST', 'STATUS')
try
{
var inventorydetail = nlapiViewCurrentLineItemSubrecord('item', 'inventorydetail');
if(inventorydetail)
{
var PIF = inventorydetail.getCurrentLineItemText('inventoryassignment', 'issueinventorynumber');
nlapiSetCurrentLineItemValue('item', 'custcol_serial_no', PIF);
return true;
}
return true;
}
catch(e)
{
nlapiLogExecution('DEBUG', 'Exeception Caught', e);
}
return true;
}
}
Any ideas?
In my own recent experience, there is no trigger on the inventorydetail "field" as it's not really a field.
Line validation is also not triggered as far as I can tell.
Only option is an afterSubmit User event script. This will be more reliable.
I'm trying to let a person fill in some details and return an overview of the details. There is an option to restart the conversation (look at code) but when the conversation is restarted and the person fill in some new details, it will show the old details of the first filled in details.
How can i fix this problem ?
bot.dialog('overview', function (session, options) {
if (session.message && session.message.value) {
if(session.message.value.actions == "Accept"){
}
return;
}
var overview_msg = require('./cards/overview.json');
var date = new Date();
overview_msg.attachments[0].content.body[0].items[1].columns[1].items[0].text = overview_msg.attachments[0].content.body[0].items[1].columns[1].items[0].text.replace(/{{name}}/,nameGuest)
overview_msg.attachments[0].content.body[0].items[1].columns[1].items[1].text = overview_msg.attachments[0].content.body[0].items[1].columns[1].items[1].text.replace(/{{date}}/,date.toDateString() +' ' + date.toLocaleTimeString());
overview_msg.attachments[0].content.body[1].items[1].facts[0].value = overview_msg.attachments[0].content.body[1].items[1].facts[0].value.replace(/{{email}}/, mailGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[1].value = overview_msg.attachments[0].content.body[1].items[1].facts[1].value.replace(/{{phone}}/, phoneGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[2].value = overview_msg.attachments[0].content.body[1].items[1].facts[2].value.replace(/{{extra}}/, numberPeople);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{lunch}}/, lunchGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{allergy}}/, lunchAllergyGuest);
overview_msg.attachments[0].content.body[1].items[1].facts[3].value = overview_msg.attachments[0].content.body[1].items[1].facts[3].value.replace(/{{vegan}}/, lunchVegan);
session.send(overview_msg);
bot.dialog('restart', function (session) {
session.beginDialog('overview');
}).triggerAction({matches: /restart|quit/i});
I think it may relate to how you define variables nameGuest, mailGuest, phoneGuest, etc which are not shown in your code snippet.
For getting values from Input.Text of adaptive-card, you can try the following code snippet:
bot.dialog('form', [
(session, args, next) => {
let card = require('./card.json');
if (session.message && session.message.value) {
next(session.message.value)
} else {
var msg = new builder.Message(session)
.addAttachment(card);
session.send(msg);
}
},
(session, results) => {
// Get the User input data here
session.send(JSON.stringify(results));
}
]).triggerAction({
matches: ['form', 'Action.Submit']
})
Yes i managed to get it done.
Instead of replacing the value in the json i referred to the variable.
example:
overview_msg.attachments[0].content.body[1].items[1].facts[0].value = VARIABLE
I'd like to store initial device title, which is accessible via GUI in browser as page title, and reuse it later in the code. E.g. I want to change name of device if it is set to some particular name only, and to store an old device name in browser console log. Code might look like this:
var some_name = 'Some Name';
var title = browser.getTitle();
console.log(title);
if (title.equals('Some Name')){
some_name = 'Some Other Name';
}
setDeviceName(some_name);
unfortunately, to that protractor responds with
TypeError: title.equals is not a function
How is it possible to extract browser title as string?
Thanks.
UPDATE:
Thanks everyone, the solution due to igniteram1 is
var some_name = 'Some Name';
some_name = browser.getTitle().then(function(webpagetitle){
if (webpagetitle === 'Some Name'){
return 'Some Other Name';
}else{
return 'Some Name'
}
});
expect(some_name).toEqual('Some Other Name');
In addition to #Sudharshan Selvraj's answer,its good practice to use strict equality === instead of == and to return the value.
var some_name = 'Some Name';
some_name = browser.getTitle().then(function(webpagetitle){
if (webpagetitle === 'Some Name'){
return 'Some Other Name';
}else{
return 'Some Name';
}
});
expect(some_name).toEqual('Some Other Name');
If you aware of the new asyc/await you may use:
expect(await browser.getTitle()).toEqual("myCustomTitle");
In protractor whatever information you need from browser will be a promise and not a string. in order to fetch the value you need to resolve the promise. look at the below example.
var title = browser.getTitle();
title.then(function(webpagetitle){
if (webpagetitle == 'Some Name'){
some_name = 'Some Other Name';
}
})
.equals() is not a function in JavaScript, but it's a valid function in Java. In Java Script, we have '==', '===' as an alternative for performing equal operations.
var x=10
== compare only values of operands, not type of operands
example:
x==10 => true
x=="10" => true
=== compare both values and type of operands
example:
x===10 => true
x==="10" => false(type of x in int and "10" is string)
var someName;
browser.getTitle().then(function (webPageTitle) {
if (webPageTitle == 'Some Name'){
someName= 'Some Other Name';
}
});
I've got a simple function in protractor to get the title when in the promise it shows the title properly, but when I do console.log it gives :
Title Got is ManagedPromise::123 {[[PromiseStatus]]: "pending"}
describe('Protractor Demo App', function() {
it('should have a title', function(one) {
browser.waitForAngularEnabled(false);
browser.get('https://tasyah.com');
titleGot = browser.getTitle().then(function(promisedResult){
console.log("Title is : " + promisedResult);
return promisedResult;
})
console.log("Title Got is " + titleGot);
expect(titleGot).toEqual('Tasyah: Online Shopping For Fashion And Costume Jewellery');
console.log("Title Got is " + titleGot);
});
});
Any explanation on this is appreciated...
Thanks
Naveen
Page Object .po file
getTableRows() {
return element.all(by.css('[data-qa="qa-table"] tr'));
}
.e2e.spec file
<PROMISE-APPROCH>
obj.getTableRows().then((list)=> {
list.count().then((totalRows)=>{
expect(totalRows).toBe(10); // example
})
});
<ASYNC-AWAIT-APPROCH>
const rowsCount = await obj.getTableRows().count();
expect(rowsCount).toBe(10); // example
I can pass values for select, text box and etc but not for multi select. I can update values for multi select. But i can't create a record by passing values for multi select.
This is the code :
$datastring = array(
"gu_action"=> "create",
"recordtype"=>"vendor",
"companyname"=>"Jerald Vend",
'subsidiary'=>1,
'custentity36'=>1
);
custentity36 is multiselect control. It's label is Course
when i pass single value , It works fine.
when i try to pass multiple values for multi select like the below code , i am getting error like "Please enter value(s) for: Course"
$datastring = array(
"gu_action"=> "create",
"recordtype"=>"vendor",
"companyname"=>"Jerald Vend",
'subsidiary'=>1,
'custentity36'=>array(1,3)
);
The Code is : https://gist.githubusercontent.com/ganeshprabhus/a3ebd67712913df3de29/raw/3a6df6a3af8642fceacb3a4b8e519ad96a054e69/ns_script.js
The value you pass is in correct format. In this case the RESTlet code should have the compatibility of handling the multiselect filed. The field set value api that used in the RESTlet should be
nlapiSetFieldValues()
This is the api can be used to set multiselect field value. As per the github refernce you shared. under the create_record function
/********************** Creation *********************************/
function create_record(datain) {
var err = new Object();
// Validate if mandatory record type is set in the request
if (!datain.recordtype) {
err.status = "Failed";
err.message = "Missing recordtype";
return err;
}
var record = nlapiCreateRecord(datain.recordtype);
for ( var fieldname in datain) {
if (datain.hasOwnProperty(fieldname)) {
if (fieldname != 'recordtype' && fieldname != 'id') {
var value = datain[fieldname];
// ignore other type of parameters
if (value && typeof value != 'object') {
record.setFieldValue(fieldname, value);
}
} //recordtype and id checking ends
}
} //for ends
var recordId = nlapiSubmitRecord(record);
nlapiLogExecution('DEBUG', 'id=' + recordId);
var nlobj = nlapiLoadRecord(datain.recordtype, recordId);
return nlobj;
}
The quoted code should be
record.setFieldValues(fieldname,value) // fieldname : custentity36 , value : 1,3
I'm new in CRM development. I know a basic thing like "best practice for crm 2011"
I wanna understand now how to work with lookup fields. And I think I chose the easiest way for my self.
I have an costum entity "contract" it has 5 more field, 2 of these are lookups.
First lookup (agl_contractId) - it is a link by it self
Second lookup (agl_ClientId) - link to Client.
What do I need?
When I choose fill First lookup (agl_contractId), script should find in this contract a Client and copy-past it to current form.
I've done script but it isn't work... (((
function GetAccountFromContract()
{
XrmServiceToolkit.Rest.Retrieve(Xrm.Page.getAttribute("agl_osnovnoy_dogovorid").getValue(),
'agl_osnovnoy_dogovoridSet',
null,null,
function (result) {
var Id = Xrm.Page.getAttribute("agl_osnovnoy_dogovorid").getValue();
if (result.Id != null) {
var LookupData = new Array();
var LookupItem = new Object();
var lookuptextvalue = lookupvalue[0].name;
var lookupid = lookupvalue[0].id;
var lokupType = lookupvalue[0].entityType;
alert(lookupvalue);
alert(lookupData);
Xrm.Page.getAttribute("agl_accountid").setValue(lookupData);
}
},
function (error) {
equal(true, false, error.message);
},
false
);
}
If I understand you well: When you select Contract in agl_osnovnoy_dogovorid field, you want to pull Client property from that Contract and put it in agl_accountid field?
If that is right:
First, get Id of selected Contract (from agl_osnovnoy_dogovorid field)
var selectedContract = new Array();
selectedContract = Xrm.Page.getAttribute("agl_osnovnoy_dogovorid").getValue();
{
var guidSelectedContract = selectedContract[0].id;
//var name = selectedContract[0].name;
//var entType = selectedContract[0].entityType;
}
Second, retrieve Client from agl_osnovnoy_dogovorid. Your oData query will be like:
http://crmserver/org/XRMServices/2011/OrganizationData.svc/ContractSet(guid'" + guidSelectedContract + "')/CustomerId
(In example I'm using CustomerId field. For your case enter Schema Name of Client field).
Now, execute query and put result into agl_accountid field:
$.getJSON(
Xrm.Page.context.getServerUrl() + "/XRMServices/2011/OrganizationData.svc/ContractSet(guid'" + guidSelectedContract + "')/CustomerId",
function(data){
if(data.d.CustomerId != null && data.d.CustomerId.Id != null && data.d.CustomerId.Id != "undefined")
{
//set agl_accountid field
Xrm.Page.getAttribute("agl_accountid").setValue([{id:data.d.CustomerId.Id, name:data.d.CustomerId.Name, typename:data.d.CustomerId.LogicalName}]);
}
});
Your using REST to retrieve data but also using FetchXml example to setup the agl_accoutid lookup.
Also some of the conditions are not clear … anyway … I’ve incorporated the change to your original post.
function GetAccountFromContract()
{
var aodLookupValue = Xrm.Page.getAttribute("agl_osnovnoy_dogovorid").getValue();
if (!aodLookupValue) return;
XrmServiceToolkit.Rest.Retrieve( aodLookupValue[0].id ,
'agl_osnovnoy_dogovoridSet', null,null,
function (result) {
var customer = result.d["your attribute name"];
if (customer) {
var LookupData = new Array();
var LookupItem = new Object();
var lookuptextvalue = customer.Name;
var lookupid = customer.Id;
var lokupType = customer.LogicalName;
alert(lookupvalue);
alert(lookupData);
Xrm.Page.getAttribute("agl_accountid").setValue(lookupData);
}
},
function (error) {
equal(true, false, error.message);
}, false );
}