I have an example, to create a sales order. I attempt to create an order with two SO lines. But I notice some unexpected results. The unit price and discount percentage amounts are incorrect. I suppose my commands are not set up properly. Please advise.
context.SetSchema(SO301000);
List<Command> cmds = new List<Command>();
cmds.AddRange(new Command[]{
//SO header
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "01/10/2015", LinkedCommand = SO301000.OrderSummary.Date },
new Value { Value = "01/12/2015", LinkedCommand = SO301000.OrderSummary.RequestedOn },
new Value { Value = "09952", LinkedCommand = SO301000.OrderSummary.CustomerOrder }, //external customer reference nbr
new Value { Value = "ABARTENDE", LinkedCommand = SO301000.OrderSummary.Customer },
new Value { Value = "NEW SALES ORDER", LinkedCommand = SO301000.OrderSummary.Description },
//set some shipping information
new Value { Value = "01/21/2015", LinkedCommand = SO301000.ShippingSettingsShippingInformation.SchedShipment },
new Value { Value = "Back Order Allowed", LinkedCommand = SO301000.ShippingSettingsShippingInformation.ShippingRule },
//add an Acumatica Stock Item to the SO transaction
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "MAIN", LinkedCommand = SO301000.DocumentDetails.Branch },
new Value { Value = "D000000000", LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse },
new Value { Value = "5", LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = "100", LinkedCommand = SO301000.DocumentDetails.UnitPrice },
//add a 3% discount percentage to the unit price of the line item
new Value { Value = "3", LinkedCommand = SO301000.DocumentDetails.DiscountPercent },
//add an Acumatica non-stock Item to the SO transaction
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "MAIN", LinkedCommand = SO301000.DocumentDetails.Branch },
new Value { Value = "ACCOMODATION", LinkedCommand = SO301000.DocumentDetails.InventoryID },
//intentially left comment line below to create an exception
new Value { Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse },
new Value { Value = "Hotel for the support team", LinkedCommand = SO301000.DocumentDetails.LineDescription }, //override the item description that is associated to the non-stock item
new Value { Value = "1", LinkedCommand = SO301000.DocumentDetails.Quantity },
new Value { Value = "300", LinkedCommand = SO301000.DocumentDetails.UnitPrice }, //its a nice hotel
SO301000.Actions.Save,
//line below allows the autonumbering sequence of the Acumatica SO order numbers, which is set up in the SO preferences screen
SO301000.OrderSummary.OrderNbr});
string orderNumber = string.Empty;
var contentReturned = context.Submit(cmds.ToArray());
orderNumber = contentReturned[0].OrderSummary.OrderNbr.Value;
}
catch (SoapException ex) { }
Set Commit = true under UnitPrice field
Here is how I have added a multiline SO. You might see something that will help.
cmds.Clear();
// create the Sales Order header
try
{
cmds.AddRange(
new SO301000_509.Command[]
{
so301000.Actions.Insert,
new SO301000_509.Value { Value = "SO", LinkedCommand = so301000.OrderSummary.OrderType },
new SO301000_509.Value { Value = "='new'", LinkedCommand = so301000.OrderSummary.OrderNbr },
new SO301000_509.Value { Value = dealerOrder.accountCode, LinkedCommand = so301000.OrderSummary.Customer },
new SO301000_509.Value { Value = (dealerOrder.orderDateTime), LinkedCommand = so301000.OrderSummary.Date },
new SO301000_509.Value { Value = "Hubsoft Order Nbr: " + dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.Description },
new SO301000_509.Value { Value = dealerOrder.hubsoftOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerRef },
new SO301000_509.Value { Value = "HS-" + dealerOrder.purchaseOrderNumber, LinkedCommand = so301000.OrderSummary.CustomerOrder },
new SO301000_509.Value { Value = dealerOrder.notes, LinkedCommand = so301000.OrderSummary.NoteText},
new SO301000_509.Value { Value = "true", LinkedCommand = so301000.ShippingSettingsShipToInfo.OverrideAddress },
new SO301000_509.Value { Value = shipStreet1, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine1 },
new SO301000_509.Value { Value = shipStreet2, LinkedCommand = so301000.ShippingSettingsShipToInfo.AddressLine2 },
new SO301000_509.Value { Value = shipCity, LinkedCommand = so301000.ShippingSettingsShipToInfo.City },
new SO301000_509.Value { Value = shipState, LinkedCommand = so301000.ShippingSettingsShipToInfo.State },
new SO301000_509.Value { Value = shipCountry, LinkedCommand = so301000.ShippingSettingsShipToInfo.Country },
new SO301000_509.Value { Value = shipPostal, LinkedCommand = so301000.ShippingSettingsShipToInfo.PostalCode },
}
);
//create the sales order lines in loop
for (var idx = 0; idx < SalesOrderLine.Length; idx++)
{
cmds.AddRange(
new SO301000_509.Command[]
{
so301000.DocumentDetails.ServiceCommands.NewRow,
//simple line adding
so301000.DocumentDetails.ServiceCommands.NewRow,
new SO301000_509.Value { Value = SalesOrderLine[idx].inventoryCD, LinkedCommand = so301000.DocumentDetails.InventoryID },
new SO301000_509.Value { Value = SalesOrderLine[idx].UOM, LinkedCommand = so301000.DocumentDetails.UOM },
new SO301000_509.Value { Value = SalesOrderLine[idx].Qty, LinkedCommand = so301000.DocumentDetails.Quantity },
new SO301000_509.Value { Value = "MAIN", LinkedCommand = so301000.DocumentDetails.Warehouse},
new SO301000_509.Value { Value = SalesOrderLine[idx].UnitPrice, LinkedCommand = so301000.DocumentDetails.UnitPrice, Commit = true },
}
);
}
cmds.Add(so301000.Actions.Save); //save all
cmds.Add(so301000.OrderSummary.OrderNbr); //return Order #
// Submit the SalesOrder to save it
SO301000_509.Content[] SO301000Content = context.Submit(cmds.ToArray()); //submit
PXTrace.WriteInformation(SO301000Content[0].OrderSummary.OrderNbr.Value);
// Retrieve the new Sales Order #
acumaticaSONbr = SO301000Content[0].OrderSummary.OrderNbr.Value;
}
catch (Exception ex)
{
PXTrace.WriteError("Error adding Sales Order - " + ex.Message);
}
return acumaticaSONbr;
}
Related
I was trying to place sales order through Web API and wanted to uncheck the "Manual Discount" checkbox so I tried to use following code:
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
List<Command> cmds = new List<Command>();
cmds.Add(new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType });
cmds.Add(new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr });
cmds.Add(new Value { Value = orderInfo.OrderCustomerInfo.AcctCD, LinkedCommand = SO301000.OrderSummary.Customer });
cmds.Add(new Value { Value = orderInfo.OrderLocationInfo.ID, LinkedCommand = SO301000.OrderSummary.Location });
cmds.Add(new Value { Value = orderInfo.ShippingTotal.ToString(), LinkedCommand = SO301000.Totals.PremiumFreight });
cmds.Add(new Value { Value = "30D", LinkedCommand = SO301000.FinancialSettingsFinancialInformation.Terms});
cmds.Add(new Value { Value = orderInfo.PromoCode, LinkedCommand = SO301000.DocumentDetails.DiscountCode });
//add line items
foreach (OrderItem item in orderInfo.OrderItems)
{
cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
cmds.Add(new Value { Value = item.InventoryCD, LinkedCommand = SO301000.DocumentDetails.InventoryID });
cmds.Add(new Value { Value = item.Quantity.ToString(), LinkedCommand = SO301000.DocumentDetails.Quantity });
cmds.Add(new Value { Value = "Server", LinkedCommand = SO301000.DocumentDetails.Warehouse });
cmds.Add(new Value { Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount});
cmds.Add(new Value { Value = "Discount1", LinkedCommand = SO301000.DocumentDetails.DiscountCode});
cmds.Add(new Value { Value = "20", LinkedCommand = SO301000.DocumentDetails.DiscountPercent });
}
cmds.Add(SO301000.Actions.Save);
cmds.Add(SO301000.OrderSummary.OrderNbr);
cmds.Add(SO301000.OrderSummary.OrderTotal);
cmds.Add(SO301000.OrderSummary.TaxTotal);
cmds.Add(SO301000.OrderSummary.Location);
cmds.Add(SO301000.OrderSummary.Customer);
SO301000Content[] SO30100content = context.SO301000Submit(cmds.ToArray());
.......................
however, after the sales order is placed, I found the "Manual Discount" checkbox was still checked and discount I have set to automatically be applied was not applied at all.
I found an old thread about this issue at http://forum.acumatica.com/forum/acumatica-reseller-and-isv-community/development-and-customization/895-order-creation-through-soap-call-with-manual-discosunt-false-not-working, in which a guy said this was a bug, however, that was about 3 years ago. so I assume this bug should have been fixed already...if it is not bug any more, can somebody tell me what I did wrong?
Thanks.
Just did more testing following the suggestion from #Gabriel but the "Manual Discount" was still checked after the order is placed through web service, however, when I tried to place a new order through screen and add same item, the "Manual Discount" was not checked by default. I don't know what was wrong in my code.
Here is the code I just tried and no luck to get discount automatically applied:
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
List<Command> cmds = new List<Command>();
cmds.Add(new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType });
cmds.Add(new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr });
cmds.Add(new Value { Value = orderInfo.OrderCustomerInfo.AcctCD, LinkedCommand = SO301000.OrderSummary.Customer });
cmds.Add(new Value { Value = orderInfo.OrderLocationInfo.ID, LinkedCommand = SO301000.OrderSummary.Location });
cmds.Add(new Value { Value = orderInfo.ShippingTotal.ToString(), LinkedCommand = SO301000.Totals.PremiumFreight });
cmds.Add(new Value { Value = "30D", LinkedCommand = SO301000.FinancialSettingsFinancialInformation.Terms});
//cmds.Add(new Value { Value = orderInfo.PromoCode, LinkedCommand = SO301000.DocumentDetails.DiscountCode });
//add line items
foreach (OrderItem item in orderInfo.OrderItems)
{
cmds.Add(SO301000.DocumentDetails.ServiceCommands.NewRow);
cmds.Add(new Value { Value = item.InventoryCD, LinkedCommand = SO301000.DocumentDetails.InventoryID });
cmds.Add(new Value { Value = item.Quantity.ToString(), LinkedCommand = SO301000.DocumentDetails.Quantity });
//cmds.Add(new Value { Value = "Server", LinkedCommand = SO301000.DocumentDetails.Warehouse });
//cmds.Add(new Value { Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount});
//cmds.Add(new Value { Value = "VOLWHMIS", LinkedCommand = SO301000.DocumentDetails.DiscountCode});
//cmds.Add(new Value { Value = "100", LinkedCommand = SO301000.DocumentDetails.DiscountPercent });
}
cmds.Add(SO301000.Actions.Save);
cmds.Add(SO301000.OrderSummary.OrderNbr);
cmds.Add(SO301000.OrderSummary.OrderTotal);
cmds.Add(SO301000.OrderSummary.TaxTotal);
cmds.Add(SO301000.OrderSummary.Location);
cmds.Add(SO301000.OrderSummary.Customer);
SO301000Content[] SO30100content = context.SO301000Submit(cmds.ToArray());
This is a bug in the product. It was initially meant as a solution to avoid recalculation of discounts when you use the copy/paste feature, but it also affected the use of web services with this screen. There's simply no way to force it to FALSE - system will also put TRUE in the field.
We have already fixed the problem internally, and the fix will be available in builds starting from 5.20.1071.
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
try
{
SO301000Content[] SO301000Content = context.SO301000Submit(
new Command[]
{
SO301000.Actions.Insert,
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "='new'", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "ABARTENDE", LinkedCommand = SO301000.OrderSummary.Customer },
//new Value { Value = DateTime.UtcNow.ToShortDateString(), LinkedCommand = SO301000.OrderSummary.Date },
new Value { Value = "this is a test order", LinkedCommand = SO301000.OrderSummary.Description },
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value {Value = "CPU00001", LinkedCommand = SO301000.DocumentDetails.InventoryID},
new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
new Value {Value = "BOX", LinkedCommand = SO301000.DocumentDetails.UOM},
new Value {Value = "1", LinkedCommand = SO301000.DocumentDetails.Quantity},
new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount },
new Value {Value = "1.01", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true },
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value {Value = "CPU00004", LinkedCommand = SO301000.DocumentDetails.InventoryID},
new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
new Value {Value = "BOX", LinkedCommand = SO301000.DocumentDetails.UOM},
new Value {Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity},
new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount},
new Value {Value = "2.02", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true},
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value {Value = "CPU00008", LinkedCommand = SO301000.DocumentDetails.InventoryID},
new Value {Value = "RETAIL", LinkedCommand = SO301000.DocumentDetails.Warehouse},
new Value {Value = "PC", LinkedCommand = SO301000.DocumentDetails.UOM},
new Value {Value = "3", LinkedCommand = SO301000.DocumentDetails.Quantity},
new Value {Value = "False", LinkedCommand = SO301000.DocumentDetails.ManualDiscount},
new Value {Value = "3.03", LinkedCommand = SO301000.DocumentDetails.UnitPrice, Commit = true},
SO301000.Actions.Save,
SO301000.OrderSummary.OrderNbr
}
);
Console.WriteLine(SO301000Content[0].OrderSummary.OrderNbr.Value);
}
catch (Exception ex)
{
}
I clarified regarding this checkbox.
well, when you use API or Copy-Paste methods this checkbox will always has value - true, it's by design.
I suggest to use second call to remove this values and/or set proper discount code.
I have a customization project which using Partners site webservice to create a case. It was working perfectly ok but after I upgraded my Acumatica from version 5.10.0537 to 5.20.0531, it has stopped working. Eventually even partners site is also upgraded to same version also. It just timed out after some time.
Below is the customization code
// Use webservice to create a case
CaseAPI.Screen context = new CaseAPI.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "https://partner.acumatica.com/Soap/SP203000.asmx";
CaseAPI.LoginResult result = context.Login("usernam", "password***");
CaseAPI.Content schema = context.GetSchema();
schema.Attributes.Attribute.Commit = true;
var commands = new CaseAPI.Command[] {
new CaseAPI.Value { Value = "contract01", LinkedCommand = schema.Case.Contract},
new CaseAPI.Value { Value = "Medium", LinkedCommand = schema.Case.Priority},
new CaseAPI.Value { Value = "this is test sub", LinkedCommand = schema.Case.Subject },
new CaseAPI.Value { Value = "this is test descrip", LinkedCommand = schema.Details.Description },
new CaseAPI.Value { Value = "Product", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "Acumatica ERP", LinkedCommand = schema.Attributes.Value, Commit = true},
new CaseAPI.Value { Value = "Product Version", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "5.0", LinkedCommand = schema.Attributes.Value, Commit = true },
new CaseAPI.Value { Value = "Version and Build Number", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "8768", LinkedCommand = schema.Attributes.Value, Commit = true },
new CaseAPI.Value { Value = "Acumatica Instance URL", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "http://www.kdss.com", LinkedCommand = schema.Attributes.Value, Commit = true },
new CaseAPI.Value { Value = "Customer Site User Name (Support)", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "myname", LinkedCommand = schema.Attributes.Value, Commit = true },
new CaseAPI.Value { Value = "Customer Site Password (Support)", LinkedCommand = schema.Attributes.Attribute},
new CaseAPI.Value { Value = "mypwd", LinkedCommand = schema.Attributes.Value, Commit = true },
schema.Actions.Submit,
};
context.Submit(commands.ToArray());
The cursor just get stuck at last line of the above code. It keeps on rolling and never comes back. Finally it times out. Any suggestions?
couple advices
did you update WSDL schema in your app after upgrade
try to simplify your code and remove for example all attributes, just leave data from the "header", will it work?
I have created a Customer Payment Method through the API using the AR301000 screen. However, I have run into an error when trying to add the payment method to a sales order. Here is my current code.
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
SO301000Content[] SO30100content = context.SO301000Submit
(
new Command[]
{
//add header info
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "000129", LinkedCommand = SO301000.OrderSummary.OrderNbr },
//add payment
new Value { Value = "VISA", LinkedCommand = SO301000.PaymentSettings.PaymentMethod },
new Value { Value = "VISA:****-****-****-7261", LinkedCommand = SO301000.PaymentSettings.CardAccountNo },
SO301000.Actions.Save
}
);
When trying to run, it gives the following error:
System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> PX.Data.PXException: Error #12: Updating 'Sales Order' record raised one or more errors. Please review. Error: 'Card/Account No' may not be empty.
Is there another Card/Account number field that must be updated?
You have to use different approach
SO301000Content orderSchema = context.SO301000GetSchema();
var commands = new Command[]
{
new Value
{
Value = orderType,
LinkedCommand = orderSchema.OrderSummary.OrderType
},
new Value
{
Value = orderNbr,
LinkedCommand = orderSchema.OrderSummary.OrderNbr
},
new Value
{
Value = "TOKENCC",
LinkedCommand = orderSchema.PaymentSettings.PaymentMethod
},
new Value
{
Value = "True",
LinkedCommand = orderSchema.PaymentSettings.NewCard
},
new Value { Value = "VISA", LinkedCommand = orderSchema.PaymentSettings.PaymentMethod },
//below you have to fill attributes (pairs key-value)
new Key
{
ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
Value = "='CCDNUM'"
},
new Value
{
Value = "4321111111111234",
LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value
},
new Key
{
ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
Value = "='CVV'"
},
new Value
{
Value = "321",
LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value
},
new Key
{
ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
Value = "='EXPDATE'"
},
new Value
{
Value = "01/2019",
LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value
},
new Key
{
ObjectName = orderSchema.PaymentSettingsCardInfoDescription.Description.ObjectName,
FieldName = orderSchema.PaymentSettingsCardInfoDescription.Description.FieldName,
Value = "='NAMEONCC'"
},
new Value
{
Value = "01/2019",
LinkedCommand = orderSchema.PaymentSettingsCardInfoDescription.Value
},
orderSchema.Actions.Save
};
I am trying to create a sales order using the Acumatica Web Service API. I have been able to pass all the required fields except the Payment Settings. Our installation uses the Authorize.NET (PX.CCProcessing.AuthorizeNetTokenizedProcessing) add-in. Is it possible to interact with the Authorize.NET add-in through the API by creating a new payment method and authorizing payment so that the employees can work the order from within Acumatica and capture the payment there.
Below is the code I am using to create my sales order. I am not sure the structure to use in order to activate the "Create New Payment Profile ID" action through the API itself. Through the GUI, it opens a popup window that copies the card to Authorize.Net and saves a Payment Profile ID record within Acumatica.
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
SO301000Content[] SO30100content = context.SO301000Submit
(
new Command[]
{
//add header info
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "<NEW>", LinkedCommand = SO301000.OrderSummary.OrderNbr },
new Value { Value = "999999", LinkedCommand = SO301000.OrderSummary.Customer },
//add line items
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "SS1121", LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity },
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "SS1122", LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity },
SO301000.DocumentDetails.ServiceCommands.NewRow,
new Value { Value = "SS1123", LinkedCommand = SO301000.DocumentDetails.InventoryID },
new Value { Value = "2", LinkedCommand = SO301000.DocumentDetails.Quantity },
//add shipping information
new Value { Value = "True", LinkedCommand = SO301000.ShippingSettingsShipToInfoOverrideContact.OverrideContact },
new Value { Value = "DEMO CHURCH SHIP", LinkedCommand = SO301000.ShippingSettingsShipToInfoOverrideContact.BusinessName },
new Value { Value = "True", LinkedCommand = SO301000.ShippingSettingsShipToInfo.OverrideAddress },
new Value { Value = "123 TEST STREET", LinkedCommand = SO301000.ShippingSettingsShipToInfo.AddressLine1 },
new Value { Value = "BUFORD", LinkedCommand = SO301000.ShippingSettingsShipToInfo.City },
new Value { Value = "GA", LinkedCommand = SO301000.ShippingSettingsShipToInfo.State },
new Value { Value = "30519", LinkedCommand = SO301000.ShippingSettingsShipToInfo.PostalCode },
new Value { Value = "FREESHIP", LinkedCommand = SO301000.ShippingSettingsShippingInformation.ShipVia },
//add totals
new Value { Value = "10.00", LinkedCommand = SO301000.Totals.PremiumFreight },
new Value { Value = "94.0000", LinkedCommand = SO301000.Totals.PackageWeight },
//add payment
SO301000.Actions.Save,
SO301000.OrderSummary.OrderNbr
}
);
New Code Error -
I am now able to insert the customer payment record but receive an error when trying to insert that card into an existing sales order.
Here is my code:
SO301000Content SO301000 = context.SO301000GetSchema();
context.SO301000Clear();
SO301000Content[] SO30100content = context.SO301000Submit
(
new Command[]
{
//add header info
new Value { Value = "SO", LinkedCommand = SO301000.OrderSummary.OrderType },
new Value { Value = "000129", LinkedCommand = SO301000.OrderSummary.OrderNbr },
//add payment
new Value { Value = "VISA", LinkedCommand = SO301000.PaymentSettings.PaymentMethod },
new Value { Value = "VISA:****-****-****-7261", LinkedCommand = SO301000.PaymentSettings.CardAccountNo },
SO301000.Actions.Save
}
);
If anybody has any ideas, I would greatly appreciate it. Thanks.
You can't use the "Create New Payment Profile ID", because it relies on an actual user in the web browser (we simply show the Authorize.net new profile page in an IFRAME). We do this to limit the exposure of the application to PCI Compliance, and this way no credit card number or sensitive information ever touches the Acumatica server. You should add the payment profile directly through the Authorize.net CIM site or CIM APIs, and pass the profile ID to Acumatica.
Unfortunately you can't pass the customer profile ID directly to the order, only the payment profile value is accepted as input, so you'll first need to add the entry using the Customer Payment Methods screen API.
AR303010Content AR301000 = context.AR303010GetSchema();
context.AR303010Clear();
AR303010Content[] AR303010content = context.AR303010Submit(
new Command[]
{
new Value { Value = "999999", LinkedCommand = AR301000.PaymentMethodSelection.Customer },
new Value { Value = "VISATOK", LinkedCommand = AR301000.PaymentMethodSelection.PaymentMethod },
new Value { Value = "AUTHTOK", LinkedCommand = AR301000.PaymentMethodSelection.ProcCenterID },
new Value { Value = "102000", LinkedCommand = AR301000.PaymentMethodSelection.CashAccount },
new Value { Value = "23640304", LinkedCommand = AR301000.PaymentMethodSelection.CustomerProfileID },
new Value { Value = "27187006", FieldName = "Value", ObjectName = "ccpIdDet"}, //Payment Profile ID, going directly to internal ccpIdDet view to bypass validation error when using AR301000.PaymentMethodDetails.Value
AR301000.Actions.Save,
AR301000.PaymentMethodSelection.CardAccountNo
});
string cardAccountNo = AR303010content[0].PaymentMethodSelection.CardAccountNo.Value;
Then when you create the sales order, you just need to specify which card to be used, as returned by AR301000 after the creation process:
//add payment
new Value { Value = "VISATOK", LinkedCommand = SO301000.PaymentSettings.PaymentMethod },
new Value { Value = cardAccountNo, LinkedCommand = SO301000.PaymentSettings.CardAccountNoCardAccountNo }, //Use card account number returned earlier, like "VISATOK:****-****-****-1111"
Below is the sample showing how to set Card Number in Sales Orders through Screen-Based API:
Content orderSchema = context.GetSchema();
orderSchema.PaymentSettings.CardAccountNo.FieldName += "!Descr";
var commands = new Command[]
{
new Value
{
Value = "SO",
LinkedCommand = orderSchema.OrderSummary.OrderType,
Commit = true
},
orderSchema.Actions.Insert,
new Value
{
Value = "ABARTENDE",
LinkedCommand = orderSchema.OrderSummary.Customer,
Commit = true
},
new Value
{
Value = "VISA",
LinkedCommand = orderSchema.PaymentSettings.PaymentMethod
},
new Value
{
Value = "VISA:****-****-****-7630",
LinkedCommand = orderSchema.PaymentSettings.CardAccountNo,
Commit = true
},
orderSchema.Actions.Save
};
context.Submit(commands);
This pattern is necessary for every selector with TextField property set in Aspx.
Hello I am very new in JSON. I have written a method which is returning JSON output like below:
[
{
"PostId": 0,
"Title": "BCS",
"ImageInfo": null,
"ShortDescription": null,
"Created": "0001-01-01T00:00:00"
},
{
"PostId": 0,
"Title": "ABC",
"ImageInfo": null,
"ShortDescription": "Corruption",
"Created": "0001-01-01T00:00:00"
}
]
My method which is returning output is below:
public string GetPost(GetPost userPost)
{
var objPosts = from p in _dbcontext.Posts
where p.CategoryId == userPost.CategoryId orderby p.PostId descending
select new
{
Title = p.Title,
ImageInfo = p.ImageInfo,
ShortDescription = p.ShortDescription,
};
var listEmail = new List<Post>();
foreach (var item in objPosts)
{
var objresult = new Post
{
Title = item.Title,
ImageInfo = item.ImageInfo,
ShortDescription = item.ShortDescription
};
listEmail.Add(objresult);
}
string output = JsonConvert.SerializeObject(listEmail);
return output;
}
I actually want to add the array name, so that my JSON ouput can be easily read. I want something like below:
{
"contacts": [
{
"PostId": 0,
"Title": "BCS",
"ImageInfo": null,
"ShortDescription": null,
"Created": "0001-01-01T00:00:00"
},
{
"PostId": 0,
"Title": "BCS",
"ImageInfo": null,
"ShortDescription": null,
"Created": "0001-01-01T00:00:00"
}
]
}
Please help.
Just change the list into dictionary like this:
var dictionaryEmail = new Dictionary<string, List<Post>>();
var listEmail = var listEmail = new List<Post>();;
foreach (var item in objPosts)
{
var objresult = new Post
{
Title = item.Title,
ImageInfo = item.ImageInfo,
ShortDescription = item.ShortDescription
};
listEmail.Add(objresult);
}
dictionaryEmail.add("Contacts", listEmail);
string output = JsonConvert.SerializeObject(dictionaryEmail);
return output;