RE: Suite script to import and run csv file

Hi Expert,In order to create a journal entry we need to populate a csv file with required fields and run in the UI.Can we write a suitte script to read the csv file and run that csv file to generate a journal entry .Could you please help out ?

AHarshini Rookie Asked on June 30, 2022 in SuiteScript.
Add Comment
4 Answers

hi Sonny,
in my case, for my work, I created a script with sutetalk to automatically import the file into the cabinet
in this way I have made the process completely automated

I hope it can be of help

code

string filename = “PeopleExpress.csv”;
byte[] fileContent = System.IO.File.ReadAllBytes(path);

public static void uploadfile(NSClient ns, string NetsuiteCartella, byte[] fileContent, string filename)
// UPLOAD file cabinet
{
ns.SetPreferences();
FolderSearch fldSearch = new FolderSearch();
FolderSearchBasic fldSrearchBasic = new FolderSearchBasic();
SearchStringField searchFolder = null;
//Name of the folder that we want to search
string searchValue = NetsuiteCartella;
//Filtering by the folder name
searchFolder = new SearchStringField();
searchFolder.@operator = SearchStringFieldOperator.@is;
//Search operator
searchFolder.operatorSpecified = true;
searchFolder.searchValue = searchValue;
//searchValue is name of the folder “Demo”
fldSrearchBasic.name = searchFolder;
fldSearch.basic = fldSrearchBasic;
// Search by isActive field which is a boolean
SearchBooleanField isActive = new SearchBooleanField();
isActive.searchValue = true;
isActive.searchValueSpecified = true;
// Invoke search() web services operation
SearchResult response = Client.Service.search(fldSearch);
//Now stroring the search result in an array
Record[] arrRecord = (Record[])response.recordList;
// Process response
if (response.status.isSuccess)
{
Console.WriteLine(“internalId : {0}”, “search is successful”);
Folder fldr = (Folder)arrRecord[0];
//Getting a specific folder from the search
string fldrId = fldr.internalId;
//Fetching the required folder’s internal ID
RecordRef refId = new RecordRef();
refId.internalId = fldrId;
//Storing the folder id
//File object created to get all the file information
File objFile = new File();
objFile.name = filename; //setting the file name
objFile.folder = refId; //setting the folder information
objFile.content = fileContent; //settig the file content
ns.SetPreferences();
WriteResponse writeResponse = Client.Service.add(objFile);
}
else
{
Console.WriteLine(“internalId : {0}”, “search not found”);
return;
}
}

 

ciao

mauro

Rookie Answered on July 19, 2022.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.