Hi,
Can somebody please provide me some sample code to add an Anticipated Incoming Wire to a dynamic order?
I'm not sure what object to create and where it goes since the Field Code Browser doesn't work for popups. Or is there a workaround for that?
Thanks,
Peter
Sample code for Anticipated (Incoming) Wires
-
- Posts: 92
- Joined: Tue Feb 04, 2014 3:34 pm
Re: Sample code for Anticipated (Incoming) Wires
Here you go. Please let me know if you have any questions.
// Add an anticipated wire to an order related ledger
ILedgersManager lm = _sps.GetService<ILedgersManager>();
// find the ledger
ILedgerInfo info = lm.Ledgers
.Where(l => l.Name == "TestLedger" && l.TrustAccount.Code == "Code1")
.SingleOrDefault();
if (info != null)
{
// load the full ledger object
IOrderLedger ledger = (IOrderLedger)lm.GetLedger(info);
IOrderInformation oi = ledger.GetOrderInformation();
// get a contact for the anticipated wire
IOrderContact contact = oi.Contacts.First();
// create a new instance of the IAnticipatedWire type
IAnticipatedWire wire = ledger.NewAnticipatedWire(contact, 1000);
ledger.AnticipatedWires.Add(wire);
// save changes
lm.ApplyChanges(ledger);
}
// Add an anticipated wire to an order related ledger
ILedgersManager lm = _sps.GetService<ILedgersManager>();
// find the ledger
ILedgerInfo info = lm.Ledgers
.Where(l => l.Name == "TestLedger" && l.TrustAccount.Code == "Code1")
.SingleOrDefault();
if (info != null)
{
// load the full ledger object
IOrderLedger ledger = (IOrderLedger)lm.GetLedger(info);
IOrderInformation oi = ledger.GetOrderInformation();
// get a contact for the anticipated wire
IOrderContact contact = oi.Contacts.First();
// create a new instance of the IAnticipatedWire type
IAnticipatedWire wire = ledger.NewAnticipatedWire(contact, 1000);
ledger.AnticipatedWires.Add(wire);
// save changes
lm.ApplyChanges(ledger);
}