Can anyone help me with the following code which is trying to enter a Shipment with a mix of Serial and Non-Serial items. The error I am receiving says "PX.Data.PXException: Error #246: Failed to commit splits row." which would have something to do with the Serial allocation but I can't point out where the issue is coming from.
SO302000Content SO302000 = oScreen.SO302000GetSchema();
oScreen.SO302000Clear();
SO302000.Actions.AddSO.Commit = true;
SO302000.AddSalesOrder.Selected.LinkedCommand = null;
SO302000.DocumentDetails.InventoryID.LinkedCommand = null;
List<Command> oCmds = new List<Command>();
//Create Header.
oCmds.Add(SO302000.Actions.Insert);
oCmds.Add(new Value { Value = sCardCode, LinkedCommand = SO302000.ShipmentSummary.Customer, Commit = true });
oCmds.Add(new Value { Value = sCardLocation, LinkedCommand = SO302000.ShipmentSummary.Location });
oCmds.Add(new Value { Value = sWhsCode, LinkedCommand = SO302000.ShipmentSummary.WarehouseID });
oCmds.Add(SO302000.Actions.Save);
//Create Lines.
foreach (DataRow dR in ds.Tables[0].Rows)
{
dPackQty = Convert.ToDouble(dR["QtyPacked"]);
if (sSONbr == dR["SONbr"].ToString() && sItemCode == dR["ItemCode"].ToString())
{
dCount = dCount + 1;
}
else
{
sSONbr = dR["SONbr"].ToString();
sItemCode = dR["ItemCode"].ToString().Trim();
dCount = 0;
//oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.AddSalesOrderOperation.ServiceCommands.DialogAnswer, Commit = true });
oCmds.Add(new Value { Value = "SO", LinkedCommand = SO302000.AddSalesOrderOperation.OrderType });
oCmds.Add(new Value { Value = sSONbr, LinkedCommand = SO302000.AddSalesOrderOperation.OrderNbr });
oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.AddSalesOrder.ServiceCommands.DialogAnswer, Commit = true });
oCmds.Add(new Key { Value = sItemCode, FieldName = SO302000.AddSalesOrder.InventoryID.FieldName, ObjectName = SO302000.AddSalesOrder.InventoryID.ObjectName });
oCmds.Add(new Value { Value = "True", LinkedCommand = SO302000.AddSalesOrder.Selected, Commit = true });
oCmds.Add(SO302000.Actions.AddSO);
oCmds.Add(new Key { Value = "='" + sSONbr + "'", FieldName = SO302000.DocumentDetails.OrderNbr.FieldName, ObjectName = SO302000.DocumentDetails.OrderNbr.ObjectName });
oCmds.Add(new Key { Value = "='" + sItemCode + "'", FieldName = SO302000.DocumentDetails.InventoryID.FieldName, ObjectName = SO302000.DocumentDetails.InventoryID.ObjectName });
oCmds.Add(new Value { Value = "0", LinkedCommand = SO302000.DocumentDetails.ShippedQty, Commit = true });
}
if (dR["IsSerial"].ToString() == "Y")
{
oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.Allocations.ServiceCommands.DialogAnswer, Commit = true });
oCmds.Add(new Value { Value = dCount.ToString(), LinkedCommand = SO302000.Allocations.ServiceCommands.RowNumber, Commit = true });
oCmds.Add(new Value { Value = dR["Serial"].ToString(), LinkedCommand = SO302000.Allocations.LotSerialNbr, Commit = true });
oCmds.Add(new Value { Value = dPackQty.ToString(), LinkedCommand = SO302000.Allocations.Quantity, Commit = true });
}
else
{
oCmds.Add(new Value { Value = "OK", LinkedCommand = SO302000.Allocations.ServiceCommands.DialogAnswer, Commit = true });
oCmds.Add(new Value { Value = dPackQty.ToString(), LinkedCommand = SO302000.Allocations.Quantity, Commit = true });
}
}
oCmds.Add(SO302000.Actions.Save);
//oCmds.Add(PO302000.DocumentSummary.TotalQty);
//oCmds.Add(PO302000.DocumentSummary.TotalAmt);
oScreen.SO302000Submit(oCmds.ToArray());
While trying to change the code that handles Non Serial item to use SO302000.DocumentDetails.ShippedQty instead of SO302000.Allocations.Quantity, it returns another error:
"PX.Data.PXRowPersistingException: Error #4: 'LineType' may not be empty."
Not sure what this one means.
Help is greatly appreciated :)
G
Please take a look
Content SO302000 = context.GetSchema();
context.Clear();
Content[] result = context.Submit(
new Command[]
{
new Value { Value = "001043", LinkedCommand = SO302000.ShipmentSummary.ShipmentNbr, Commit = true },
new Value { Value = "000819", LinkedCommand = SO302000.DocumentDetails.OrderNbr, Commit = true},
new Value { Value = "OK", LinkedCommand = SO302000.BinLotSerialNumbers.ServiceCommands.DialogAnswer, Commit = true },
SO302000.BinLotSerialNumbers.ServiceCommands.NewRow,
new Value { Value = "0-_", LinkedCommand = SO302000.BinLotSerialNumbers.Subitem },
new Value { Value = "WR01", LinkedCommand = SO302000.BinLotSerialNumbers.Location },
new Value { Value = "17SNR000751", LinkedCommand = SO302000.BinLotSerialNumbers.LotSerialNbr },
SO302000.Actions.LSSOShipLineBinLotSerial,
SO302000.Actions.Save
}
);
Console.WriteLine();
Related
Current code
async function checkPoint(arrayPoint, collection, origin){
const trial = await collection.findOne({ 'Points': { $exists: true, }})
if(trial == null){
collection.insertOne({Points: ['floater', '1']})
trial = await collection.findOne({ 'Points': { $exists: true, }})
}
foundPoint = false;
pointArray = trial.Points
for(let i = 0; i < pointArray.length; i++){
newPoint = pointArray[i]
newID = newPoint[0]
newValue = newPoint[1]
if(newID == arrayPoint){
console.log("It seems we have data ! Aha !" + arrayPoint )
val = parseInt(newValue)
val = value + 1;
val = value.toString();
newValue = val;
pointArray[i] = [newId, newValue]
await collection.updateOne(trial, {$set: {'Points': pointArray}} )
foundPoint = true
}
else{
console.log("It seems id: " + arrayPoint + " doesn't match id " + newID)
}
}
if (foundPoint == false){
pointArray.push([arrayPoint, '1'])
await collection.updateOne(trial,{$set: {'Points': pointArray}} )
}
}
The code executes itself perfectly, but doesn't change 'points' without anything
I tried basic bug fixing, looking at documentation and couldn't find anything about passing arrays.
the value it passes is
{
acknowledged: true,
modifiedCount: 0,
upsertedId: null,
upsertedCount: 0,
matchedCount: 0
}
Usually I refuse to give an answer if required information are not delivered or if comments are rejected, but I make an exception. If you would have run console.log(tojson(trial)) as suggested in my comment, you would see immediately that trial is
{ _id: ObjectId("6389ea1d06..."), Points: { ["floater", ["1", "NaN"] ] }
but not
{ _id: ObjectId("6389ea1d06..."), Points: { ["floater", "1"] }
as you may assume.
Your problem is this code:
pointArray = trial.Points // <- pointArray is not a copy of trial.Points, it is a reference to original object
for (let i = 0; i < pointArray.length; i++) {
newPoint = pointArray[i]
newID = newPoint[0]
newValue = newPoint[1]
if (newID == arrayPoint) {
console.log("It seems we have data ! Aha !" + arrayPoint)
val = parseInt(newValue)
val = value + 1;
val = value.toString();
newValue = val;
pointArray[i] = [newId, newValue]
await collection.updateOne(trial, { $set: { 'Points': pointArray } })
foundPoint = true
} else {
console.log("It seems id: " + arrayPoint + " doesn't match id " + newID)
}
}
Maybe it becomes clear if I rewrite it. Below code does exactly the same:
for (let i = 0; i < trial.Points.length; i++) {
newPoint = trial.Points[i]
newID = newPoint[0]
newValue = newPoint[1]
if (newID == arrayPoint) {
console.log("It seems we have data ! Aha !" + arrayPoint)
val = parseInt(newValue)
val = value + 1;
val = value.toString();
newValue = val;
trial.Points[i] = [newId, newValue] // <- here is the problem
await collection.updateOne(trial, { $set: { 'Points': trial.Points } })
foundPoint = true
} else {
console.log("It seems id: " + arrayPoint + " doesn't match id " + newID)
}
}
I would suggest to update collection like this:
await collection.updateOne({ _id: trial._id }, { $set: { 'Points': trial.Points } })
I am trying to edit the GetOrgChart node by pointing it to a url which needs the id of the corresponding node to work. I am stuck here and would like the solution out. My code is as follows
getOrgChart.themes.monica.box += '<g transform="matrix(1,0,0,1,350,10)">'
+ btnAdd
+ btnEdit
+ btnDel
+ '</g>';
var orgChart = new getOrgChart(chartElement, {
scale: 0.5,
theme: "monica",
primaryFields: resp2.primaryFields,
photoFields: [resp2.photoField],
enableZoom: true,
enableEdit: true,
enableDetailsView: true,
dataSource: processed
});
function getNodeByClickedBtn(el) {
while (el.parentNode) {
el = el.parentNode;
if (el.getAttribute("data-node-id"))
return el;
}
return null;
}
var init = function () {
var btns = document.getElementsByClassName("btn");
for (var i = 0; i < btns.length; i++) {
btns[i].addEventListener("click", function () {
var nodeElement = getNodeByClickedBtn(this);
var action = this.getAttribute("data-action");
var id = nodeElement.getAttribute("data-node-id");
var node = orgChart.nodes[id];
switch (action) {
case "add":
window.location.href='${request.contextPath}' + resp2.addLink;
break;
case "edit":
//console.log('&id=' + processed['id']);
// return;
window.location.href='${request.contextPath}' + resp2.editLink + '&id=' + resp.data[]['id'];
break;
case "delete":
window.location.href='${request.contextPath}' + resp2.deleteLink;
break;
}
});
}
}
init();
},
error: function (ex) {
console.log(ex);
}
});
},
error: function (ex) {
console.log(ex);
}
});
The problem code is here
case "edit":
//console.log('&id=' + processed['id']);
// return;
window.location.href='${request.contextPath}' + resp2.editLink + '&id=' + resp.data[]['id'];
break;
What should I do to access the id in the resp.data[index] variable?
I got my answer. The example extracted variables and id of the node was one of them.
var nodeElement = getNodeByClickedBtn(this);
var action = this.getAttribute("data-action");
var id = nodeElement.getAttribute("data-node-id");
var node = orgChart.nodes[id];
I am creating a Shipment using Screen based Web Service call in Acumatica. The Program executes without errors and gives error Sales Order # does not exist (even if it does exist).
The program goes till the end and for some orders create a Shipment ! How do I check only specific Lines be included in the shipment in this code ??
` PSOrders.Current = psorderrec;
if (psorderrec.Status == PSOrderStatus.Hold)
{
throw new PXException(String.Format(
"Preshipment(0) is On Hold and cannot be generated.",
psorderrec.PSOrderNbr));
}
else if (psorderrec.Status != PSOrderStatus.Open)
{
throw new PXException(String.Format(
"Vendor {0} is already Processed.", psorderrec.PSOrderNbr));
}
so302000.Screen scr = new so302000.Screen();
scr.CookieContainer = new System.Net.CookieContainer();
so302000.LoginResult lr = scr.Login("USERNAME#COMPANYNAME:BRANCHNAME", "Password");
if (lr != null && lr.Code == so302000.ErrorCode.OK)
{
so302000.Content schema = scr.GetSchema();
var selectSOWithCommit = schema.Actions.SelectSO;
selectSOWithCommit.Commit = true;
var addSOWithCommit = schema.Actions.AddSO;
addSOWithCommit.Commit = true;
List<so302000.Command> commands = new List<so302000.Command>();
commands.Add(schema.Actions.Insert);
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.Customer,
Value = psorderrec.CustomerCD
});
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.Location,
Value = psorderrec.Location
});
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.WarehouseID,
Value = psorderrec.Warehouse
});
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.NoteText,
Value = psorderrec.PSOrderType+ "/" + psorderrec.PSOrderNbr
});
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.ControlQuantity,
Value = psorderrec.ControlQty.ToString()
});
commands.Add(new so302000.Value
{
LinkedCommand = schema.ShipmentSummary.Operation,
Value = "Issue"
});
commands.Add(new so302000.Value
{
Value = "OK",
LinkedCommand =
schema.AddSalesOrderOperation.ServiceCommands.DialogAnswer,
Commit = true
});
string pstype = psorderrec.PSOrderType;
string psordernbr = psorderrec.PSOrderNbr;
foreach (PSLine pslinerec in
PXSelect<PSLine,
Where<PSLine.pSOrderType, Equal<Required<PSLine.pSOrderType>>,
And<PSLine.pSOrderNbr, Equal<Required<PSLine.pSOrderNbr>>>>>.Select(this, pstype, psordernbr))
{
commands.Add(addSOWithCommit);
commands.Add(new so302000.Value
{
Value = pslinerec.SOOrderType,
LinkedCommand = schema.AddSalesOrderOperation.OrderType
});
commands.Add(new so302000.Value
{
Value = pslinerec.SOOrderNbr,
LinkedCommand = schema.AddSalesOrderOperation.OrderNbr
});
commands.Add(new so302000.Value
{
Value = "True",
LinkedCommand = schema.AddSalesOrder.Selected
});
commands.Add(schema.AddSalesOrder.InventoryID);
commands.Add(schema.AddSalesOrder.Quantity);
commands.Add(schema.AddSalesOrder.LineDescription);
var soLines = scr.Submit(commands.ToArray());
// List commandList = new List();
for (int index = 0; index < soLines.Length; index++)
{
commands.Add(addSOWithCommit);
commands.Add(new so302000.Value
{
Value = index.ToString(),
LinkedCommand =
schema.AddSalesOrder.ServiceCommands.RowNumber
});
commands.Add(new so302000.Value
{
Value = "True",
LinkedCommand = schema.AddSalesOrder.Selected,
Commit = index < soLines.Length - 1
});
}
}
commands.Add(schema.Actions.Save);
// commandList.Add(schema.Actions.Save);
scr.Submit(commands.ToArray());
scr.Logout();`
Below is a code sample that will create a shipment using Screen-Based API.
It's a bit more verbose that your example - but I think you will see some similarities to your example as well. This code starts just after the Login.
There is a section that Adds the SO, and then iterates through each line in the SO in order to update the values.
I hope this helps!
var schema = shipScreen.GetSchema();
var SelectSO = schema.Actions.SelectSO;
SelectSO.Commit = true;
var AddSO = schema.Actions.AddSO;
AddSO.Commit = true;
var Allocation = schema.Actions.LSSOShipLineBinLotSerial;
Allocation.Commit = true;
var commands = new Command[] {
//first specify keys
new Value { Value = "Shipment", LinkedCommand = schema.ShipmentSummary.Type },
new Value { Value = OrderID.Trim(), LinkedCommand = schema.ShipmentSummary.ShipmentNbr },
//header
new Value { Value = CustID, LinkedCommand = schema.ShipmentSummary.Customer },
new Value { Value = ShipName, LinkedCommand = schema.ShipmentSummary.Location },
new Value { Value = SiteID, LinkedCommand = schema.ShipmentSummary.WarehouseID },
new Value { Value = ShipDate.ToString(), LinkedCommand = schema.ShipmentSummary.ShipmentDate },
new Value { Value = "False", LinkedCommand = schema.ShipmentSummary.Hold },
//Add sales order
new Value { Value = "OK", LinkedCommand = schema.AddSalesOrderOperation.ServiceCommands.DialogAnswer, Commit = true }, SelectSO,
new Value { Value = OrderType, LinkedCommand = schema.AddSalesOrderOperation.OrderType }, // setting filter
new Value { Value = OrderID, LinkedCommand = schema.AddSalesOrderOperation.OrderNbr }, schema.AddSalesOrder.InventoryID
};
var soLines = shipScreen.Submit(commands.ToArray()); // get list of SO lines
List<Command> cmdList = new List<Command>();
for (int i = 0; i < soLines.Length; i++) // select each line
{
cmdList.Add(new Value { Value = i.ToString(), LinkedCommand = schema.AddSalesOrder.ServiceCommands.RowNumber });
cmdList.Add(new Value { Value = "True", LinkedCommand = schema.AddSalesOrder.Selected, Commit = true });
}
cmdList.Add(AddSO); //add selected lines to shipment
shipScreen.Submit(cmdList.ToArray());
//dt is the datatable with the fields that need to be entered - from the outside (non-acumatica) database
//There is one row in dt for each line needed in the shipment.
LineCounter = 0;
foreach (DataRow dr in dt.Rows)
{
ProductID = dr.Field<string>("ProductID").Trim();
LotNumber = dr.Field<string>("LotNumber").Trim();
LineNum = dr.Field<int>("LineNumber").ToString();
LinePickQty = dr.Field<Int32>("PickQty").ToString();
SiteID = dr.Field<string>("SiteID").Trim();
LocationID = dr.Field<string>("LocationID").Trim();
UOM = dr.Field<string>("UOM").Trim();
LotPickQty = dr.Field<Int32>("LotQty").ToString();
if (LineCounter == 0)
{
cmdList.Clear();
}
cmdList.Add(new Key { Value = "='" + LineNum + "'", FieldName = schema.DocumentDetails.OrderLineNbr.FieldName, ObjectName = schema.DocumentDetails.OrderLineNbr.ObjectName });
cmdList.Add(new Value { Value = SiteID, LinkedCommand = schema.DocumentDetails.Warehouse });
cmdList.Add(new Value { Value = LocationID, LinkedCommand = schema.DocumentDetails.Location });
cmdList.Add(new Value { Value = UOM, LinkedCommand = schema.DocumentDetails.UOM });
cmdList.Add(new Value { Value = LinePickQty, LinkedCommand = schema.DocumentDetails.ShippedQty, Commit = true });
cmdList.Add(new Value { Value = LinePickQty, LinkedCommand = schema.Allocations.Quantity });
cmdList.Add(new Value { Value = "OK", LinkedCommand = schema.Allocations.ServiceCommands.DialogAnswer, Commit = true });
LineCounter = LineCounter + 1;
}
//Save
cmdList.Add(schema.Actions.Save);
cmdList.Add(schema.ShipmentSummary.ShipmentNbr);
var shipment = shipScreen.Submit(cmdList.ToArray());
When I am trying to download the DocuSign Signed File, it is being downloaded but
the issue is that the file had some dropdowns and textboxes, and in downloaded file, the dropdowns and textboxes display encrypted data and not the real filled data, and one more issue is there, after the completion of document, I received the signed file on my email but the selected dropdown value overlaps over the following textbox and the signed pdf becomes non-readable.
The code for downloading the file goes like this
// read how many documents are in the envelope
int docCount = docsList.EnvelopeDocuments.Count;
string filePath = null;
FileStream fs = null;
// loop through the envelope's documents and download each doc
for (int i = 0; i < docCount; i++)
{
// GetDocument() API call returns a MemoryStream
MemoryStream docStream = (MemoryStream)envelopesApi.GetDocument(accountId, envelopeId, docsList.EnvelopeDocuments[i].DocumentId);
// let's save the document to local file system
filePath = Path.GetTempPath() + Path.GetRandomFileName() + ".pdf";
fs = new FileStream(filePath, FileMode.Create);
docStream.Seek(0, SeekOrigin.Begin);
docStream.CopyTo(fs);
fs.Close();
Console.WriteLine("Envelope Document {0} has been downloaded to: {1}", i, filePath);
}
But the downloaded file will look like this with encrypted data
And this is the following document which I received on email after completion of the document, the first column is dropdown selected value which overlaps
This is how envelope request is created
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = _objLOA.Subject;
envDef.EmailBlurb = _objLOA.EmailBody;
string recipientEmail = _objLOA.ToEmail;
if(string.IsNullOrEmpty(_objLOA.RecipientName))
{
_objLOA.RecipientName = "Animesh";
}
string recipientName = _objLOA.RecipientName;
string templateRoleName = "Customer";
string TemplateId = "xxxxxx";
// assign recipient to template role by setting name, email, and role name. Note that the
// template role name must match the placeholder role name saved in your account template.
TemplateRole tRole = new TemplateRole();
var dropdownItems1 = new List<ListItem>();
var dropdownItems2 = new List<ListItem>();
var dropdownItems3 = new List<ListItem>();
var dropdownItems4 = new List<ListItem>();
var dropdownItems5 = new List<ListItem>();
var dropdownItems6 = new List<ListItem>();
var dropdownItems7 = new List<ListItem>();
var dropdownItems8 = new List<ListItem>();
var dropdownItems9 = new List<ListItem>();
var dropdownItems10 = new List<ListItem>();
dropdownItems1.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems2.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems3.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems4.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems5.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems6.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems7.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems8.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems9.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
dropdownItems10.Add(new ListItem()
{
Text = "Select",
Value = "-1",
Selected = "true"
});
foreach (Utility itemUtility in _objutilityList)
{
dropdownItems1.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems2.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems3.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems4.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems5.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems6.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems7.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems8.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems9.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
dropdownItems10.Add(new ListItem()
{
Text = itemUtility.Name,
Value = itemUtility.Id.ToString()
});
}
List<Text> _listText = new List<Text>();
int rowNumber = 1;
foreach(LOACustomerData _loaresponseitem in _objLOA.LOACustomerData)
{
Text itemTextESI = new Text();
Text itemTextAddress = new Text();
itemTextESI.TabLabel = "txtESI" + rowNumber;
itemTextESI.OriginalValue = _loaresponseitem.AccountNumber;
itemTextESI.Value = _loaresponseitem.AccountNumber;
itemTextAddress.TabLabel = "txtServiceAddress" + rowNumber;
itemTextAddress.OriginalValue = _loaresponseitem.ServiceAddress;
itemTextAddress.Value = _loaresponseitem.ServiceAddress;
_listText.Add(itemTextAddress);
_listText.Add(itemTextESI);
if (rowNumber == 1)
{
ListItem item = dropdownItems1.Find(x => x.Value == _loaresponseitem.UtilityId.ToString());
if(item!=null)
item.Selected = "true";
}
else if (rowNumber == 2)
{
dropdownItems2.Find(x => x.Value == "-1").Selected = "false";
dropdownItems2.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
}
else if (rowNumber == 3)
dropdownItems3.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 4)
dropdownItems4.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 5)
dropdownItems5.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 6)
dropdownItems6.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 7)
dropdownItems7.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 8)
dropdownItems8.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 9)
dropdownItems9.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
else if (rowNumber == 10)
dropdownItems10.Find(x => x.Value == _loaresponseitem.UtilityId.ToString()).Selected = "true";
rowNumber++;
if (rowNumber > 10)
break;
}
tRole.Tabs = new Tabs()
{
TextTabs = _listText,
ListTabs = new List<List>()
{
new List(){ TabLabel = "ddlUtility1", ListItems = dropdownItems1 },
new List(){ TabLabel = "ddlUtility2", ListItems = dropdownItems2 },
new List(){ TabLabel = "ddlUtility3", ListItems = dropdownItems3 },
new List(){ TabLabel = "ddlUtility4", ListItems = dropdownItems4 },
new List(){ TabLabel = "ddlUtility5", ListItems = dropdownItems5 },
new List(){ TabLabel = "ddlUtility6", ListItems = dropdownItems6 },
new List(){ TabLabel = "ddlUtility7", ListItems = dropdownItems7 },
new List(){ TabLabel = "ddlUtility8", ListItems = dropdownItems8 },
new List(){ TabLabel = "ddlUtility9", ListItems = dropdownItems9 },
new List(){ TabLabel = "ddlUtility10", ListItems = dropdownItems10 }
}
};
tRole.Email = recipientEmail;
tRole.Name = recipientName;
tRole.RoleName = templateRoleName;
List<TemplateRole> rolesList = new List<TemplateRole>() { tRole };
envDef.TemplateRoles = rolesList;
envDef.TemplateId = TemplateId;
envDef.Status = "sent";
EnvelopesApi envelopesApi = new EnvelopesApi(cfi);
EnvelopeSummary envelopeSummary = envelopesApi.CreateEnvelope(accountID, envDef);
I am currently in need of automating the creation of bank deposits using the screen based API.
What would be the best way of doing this?
This is how I managed to do it:
class Payment
{
public string Module;
public string Type;
public string RefNbr;
public decimal Amount;
}
class Program
{
static void Main(string[] args)
{
var paymentsToDeposit = new Payment[]
{
new Payment { Module = "AR", Type = "Payment", RefNbr = "000483", Amount = 100 },
new Payment { Module = "AR", Type = "Payment", RefNbr = "000484", Amount = 200 },
};
Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/bankDeposits/(W(53))/Soap/CA305000.asmx";
context.Login("admin", "admin");
Content bankDepositSchema = context.GetSchema();
List<Command> commands = new List<Command>();
commands.Add(new Value { Value = "<NEW>", LinkedCommand = bankDepositSchema.DepositSummary.ReferenceNbr });
commands.Add(new Value { Value = "102000", LinkedCommand = bankDepositSchema.DepositSummary.CashAccount });
commands.Add(new Value { Value = "test2", LinkedCommand = bankDepositSchema.DepositSummary.DocumentRef });
commands.Add(new Value { Value = "OK", LinkedCommand = bankDepositSchema.AddPaymentToDeposit.ServiceCommands.DialogAnswer, Commit = true });
decimal total = 0;
foreach(Payment pmt in paymentsToDeposit)
{
commands.Add(new Key { Value = "='" + pmt.Module + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.DocModule.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.DocModule.ObjectName });
commands.Add(new Key { Value = "='" + pmt.Type + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.Type.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.Type.ObjectName });
commands.Add(new Key { Value = "='" + pmt.RefNbr + "'", FieldName = bankDepositSchema.AddPaymentToDeposit.ReferenceNbr.FieldName, ObjectName = bankDepositSchema.AddPaymentToDeposit.ReferenceNbr.ObjectName });
commands.Add(new Value { Value = "True", LinkedCommand = bankDepositSchema.AddPaymentToDeposit.Selected, Commit = true });
total += pmt.Amount;
}
commands.Add(bankDepositSchema.Actions.AddPayment);
commands.Add(new Value { Value = total.ToString(System.Globalization.CultureInfo.InvariantCulture), LinkedCommand = bankDepositSchema.DepositSummary.ControlTotal });
commands.Add(bankDepositSchema.Actions.Save);
context.Submit(commands.ToArray());
context.Logout();
}
}