Scheduled CSV Import's Deployement Error In Netsuite - netsuite

I tried to update the employees record in an Netsuite system using the Scheduled CSV Import.
while deploying the Scheduled Script, I put the status has "Testing" and click "Save & Execute" Button for testing purpose.
And then I checked the Execution Log in the Log it shows the following error message:
" com.netledger.app.common.scripting.version1.nlobjCSVImportImplV1"
Scheduled Script Code:
function scheduled(type) {
var fileId = nlapiGetContext().getSetting('SCRIPT', 'custscript_sfg_customer_rec_cus_param');
nlapiLogExecution('DEBUG','fileId:',fileId);
var import1 = nlapiCreateCSVImport();
nlapiLogExecution('DEBUG','import1:',import1);
var mapping = import1.setMapping('CUSTIMPORT_emp_rec_imp');
// Internal id for mapping
nlapiLogExecution('DEBUG','mapping:',mapping);
var setPrimary = import1.setPrimaryFile(nlapiLoadFile(fileId));
// id is Internal id for Employee file
nlapiLogExecution('DEBUG','setPrimary:',setPrimary);
var submitImport = nlapiSubmitCSVImport(import1);
// Importing is Done
nlapiLogExecution('DEBUG','submitImport:',submitImport);
}
Help me to find the solution for creating the scheduled CSV Import.
Thanks in Advance.

There are a couple of possible issues with your code:
When I have done this I've used all lower case for the import id. e.g. use 'customimport_emp_rec_imp' not 'CUSTIMPORT_emp_rec_imp'
Make sure the saved csv import definition is public
Set a job name with import1.setOption("jobName", "Employee Import");

Related

Add multiple sameday events Calendar in sheets - Script AutoRun [duplicate]

I'm trying to create calendar events in sheets using Google App Script (I'm very new to this). The sheet contains details of the event (date, time, event title, and guest list) as well as the calendar ID (this is a training calendar). I want to make it simple for the end-user to fill in the information on the sheet, click 'schedule now' and the script run and send the events out to all email addresses mentioned in the guest list.
Here is an example of the sheet:
Here is a copy of the code (I found this on the Google Developer website and tried to adapt it to add guests but haven't been able to get it working and really not sure where to go with this. Ideally, I'd like the guest list to come from the sheet and not be written into the code as an option.
function scheduleTraining() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var calendarId = spreadsheet.getRange("C3").getValue();
var eventCal = CalendarApp.getCalendarById(calendarId);
Logger.log(eventCal)
var signups = spreadsheet.getRange("A5:C20").getValues();
for (x=0; x<signups.length; x++) {
var shift = signups[x];
var startTime = shift[0]
var endTime = shift[1]
var title = shift[2]
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
})
}
}
function onOpen(e) {
SpreadsheetApp.getUi()
.createMenu('Schedule Training')
.addItem('Schedule Now', 'scheduleTraining')
.addToUi();
}
If anyone can help with this or has any ideas on how to do this better, I'm all ears!
Thanks!
Issues:
The dates in your spreadsheet file are strings/texts. You can verify that if you do =isDate(A7). If the latter returns FALSE then you don't have a valid date object. If you see the official documentation you need to pass date objects and not date texts.
Another remark I have is that your range is "A5:C20" but you should start from A7. Row 5 and 6 don't contain the information required, according to your screenshot.
Question based on your comment:
how I can include inviting the guests when it's run
Again according to the documentation, you can add guests using the advanced parameters options and in particular guests:
eventCal.createEvent(title, startTime, endTime, {
location: 'remote',
description: 'snacks provided',
guests: 'test1#gmail.com,test2#gmail.com'
})
guests is a type of string that contains a comma-separated list of email addresses
that should be added as guests.

is there a way to only import price data on Netsuite

I need to have 400+ price levels on Netsuite, but for the life of me, I can't find a way to add them through imports. From what I've seen and tried, Netsuite only allows you to upload items that reference existing price levels but doesn't allow you to upload new ones. Does anyone know how this could be done?
Price levels are scriptable.
Since this is just a one time job you could do this in a console window (inspect any editable standard record and find/show the console)
You will likely run into a governance error running this on 400 names but just
note the last name successfully created
refresh the page you have open
delete the names lines down through the last successful one
re-run the script
repeat until they are all created.
require(['N/record'], record=>{
const names = [
'Test Level 1' // use your whole list of names
'Test Level 2', // etc
];
names.forEach(n=>{
try{
const pr = record.create({type:'pricelevel'});
pr.setValue({fieldId:'name', value:n});
// make your array of names more complex to handle discounts etc.
//pr.setValue({fieldId:'discountpct', value:xx});
pr.save();
console.log('created', n);
}catch(e){
console.error(n, e);
}
});
console.log('done');
});

Finding role and script deployment relations im Netsuite

Is it possible to easily see which roles have access to which script deployments?
I tried making a script deployments saved search as well as a role saved search but could not really find out how to extract this information.
Does anyone know?
I cannot see a way to complete this in the UI/via saved search. You can complete this via suitescript however by following this sort of layout. You can schedule the script to run periodically, or just run in the browser console to get the data you want. You can also add code to create an excel file to easily digest the information...
Layout in SS2.0
//gather all applicable role ids
var Roles = [];
//gather all applicable script deployment ids
var ScriptDep = [];
//for each script deployment id get the "Roles" from the "Audience" tab in the UI
for (var i=0; i<ScriptDep.length; i++){
var script = record.load({
type: 'scriptdeployment',
id: ScriptDep[i]
});
var scriptAudienceField = script.getField({
fieldId: 'audslctrole'
});
var scriptAudience = scriptAudienceField.getSelectOptions({
filter : '*',
operator : 'contains'
});
var RoleID = ; //role ID you care about, maybe loop through all roles with Roles[j]
var test = scriptAudience.includes(RoleID); //returns true or false this deployment is deployed to this role
}
Suite Answer 86327 gives the dollowing SS1.0 sample code
var search = nlapiLoadSearch('scriptdeployment', 147); //load search of all script deployments
var resultSet = search.runSearch();
resultSet.forEachResult(function(searchResult){ //for each script deployment returned by the search, get the id
var record = nlapiLoadRecord('scriptdeployment', searchResult.id); //load the script deployemnt
var arrayOfRoles = record.getFieldValues('audslctrole'); //get the values of the "Roles" from the "Audience" tab in the UI
if(arrayOfRoles == '18'){ //change based on the internal ID of the role
console.log(searchResult.id);
};
return true;
});

How to create an image import job using KTA SDK?

I am trying to create a job using SDK. Simple job with send email activity work like a charm!
But when I try to create a job with variables input folder to import few images it doesn't work at all. Am I missing very trivial settings ?
My process has classification activity & extraction activities
Variables : DefaultImportFolder
FYI : My process works fine if I set import settings -> import sources. That tells me there is no issue with my process process Smile. But when I try to run through console app with dynamic variables, it doesn't work.
Following is my sample code. Any help?
ProcessIdentity processIdentity = new ProcessIdentity
{
Name = "SDK TestProcess"
};
var jobService = new TotalAgility.Sdk.JobService();
JobInitialization jobInitialization = new JobInitialization();
InputVariableCollection variablesCollections = new InputVariableCollection();
InputVariable inputVariable = new InputVariable
{
Id = "DefaultImportFolder",
Value = #"\\FolderPath",
};
variablesCollections.Add(inputVariable);
inputVariable = new InputVariable
{
Id = "ExportSuccess",
Value = "true"
};
variablesCollections.Add(inputVariable);
var createJobAndProgress = jobService.CreateJob(sessionId, processIdentity, jobInitialization);
Console.WriteLine($"Job ID {createJobAndProgress.Id}");
As Suggested by Steve, tried with WithDocuments method Still no luck .....
JobWithDocumentsInitialization jobWithDocsInitialization = new JobWithDocumentsInitialization();
Agility.Sdk.Model.Capture.RuntimeDocumentCollection documentsCollection = new Agility.Sdk.Model.Capture.RuntimeDocumentCollection();
Agility.Sdk.Model.Capture.RuntimeDocument runtimeDoc = new Agility.Sdk.Model.Capture.RuntimeDocument
{
FilePath = #"FolderPath\abc.tif",
};
documentsCollection.Add(runtimeDoc);
jobWithDocsInitialization.Documents = documentsCollection;
var jobIdentity = jobService.CreateJobWithDocuments(sessionId, processIdentity, jobWithDocsInitialization);
Console.WriteLine($"Job ID {jobIdentity.Id}");
A folder variable represents a reference to a folder that already exists in the KTA database, so you can't just set a file path to the variable. When you create a job via an import source, it is creating the folder and documents as part of creating the job.
To do the same in your code, you would use one of the "WithDocuments" APIs such as CreateJobWithDocuments which has parammeters specific to importing documents into the process, including by file path.
As discussed in this other answer (Kofax TotalAgility Send a PDF Document to Jobs Queue (KTA)), you may want to look at the sample code that is included with the product (that most people don't realize is available), and also look at other API functions for more context on the parameters needed for the "WithDocuments" APIs mentioned above.

Get users information when creating a customer

I'm trying to create a Prestashop Module which when a user is created, I can get all his information automatically using ActionCustomerAccountAdd, this event return ($params), but I don't know the structure of the object params for getting the data needed
I tried to create hookActionCustomerAccountAdd which get params, I was able to get just the email of the customer $params['newCustomer']->email, but I can't get the first name and last name and the password
// Will be executed each times actionCustomerAccountAdd is triggered
public function hookActionCustomerAccountAdd($params)
{
// $params is an array set by PrestaShop which contains the
// hook data (here, the customer details
$this->CustomerAdd($params['newCustomer']->email);
/* $json_output = json_decode($params,true);
var_dump($json_output) ;
echo "Works";
*/
}
public function CustomerAdd($mail){
$myObj->userx->UserID = 0;
$myObj->userx->Username = "NameUser";
$myObj->userx->Password ="Password";
$myObj->userx->Fname ="Fname";
$myObj->userx->Lname= "Lname";
$myObj->userx->Mail= $mail;
$myObj->username= "evdokimosk";
$myObj->password="123425";
}
I expect to get all data I need like first name, last name but I don't know what is inside the $params
$params['newCustomer'] is the object of the client, so you can retrieve customer information: :
$firstname = $params['newCustomer']->firstname;
$lastname = $params['newCustomer']->lastname;
....
Regards

Resources