If you would like to create a expense report that is in progress via c# below is the sample on how to do it.
Please note a valid login session is required.
if (stat.isSuccess)
{
// Creating a Record Ref Object for an employee
RecordRef employee = new RecordRef();
employee.internalId = "418";
// Creating Expense Report Objects
ExpenseReportExpenseList expList = new ExpenseReportExpenseList();
ExpenseReportExpense[] expense = new ExpenseReportExpense[1];
ExpenseReportExpense exp1 = new ExpenseReportExpense();
// Creating a RecordRef Object for a category
RecordRef category = new RecordRef();
category.internalId = "1";
// Creating a RecordRef Object for currency
RecordRef currency = new RecordRef();
currency.internalId = "3";
// Applying the appropriate object to there counter parts
expList.expense = expense;
expense[0] = exp1;
// Building the expense report line item
exp1.expenseDate = System.DateTime.Now;
exp1.expenseDateSpecified = true;
exp1.category = category;
exp1.currency = currency;
exp1.amount = 5.00;
exp1.amountSpecified = true;
// Creating the Expense report object.
ExpenseReport report = new ExpenseReport();
report.entity = employee;
report.tranDate = System.DateTime.Now;
report.tranDateSpecified = true;
report.complete = false;
report.completeSpecified = true;
// Assigning the ExpenseReportExpenseList object to the required ExpenseList
report.expenseList = expList;
// Sending in the add request to NetSuite
WriteResponse res = nss.add(report);
// Seeing if the expense report was added successfully.
if (res.status.isSuccess)
{
Console.WriteLine("Expense Report Successfully Added");
Console.Read();
}
else
{
Console.WriteLine("Expense Report not added");
Console.Read();
}
}
No comments:
Post a Comment