Samples
•
Version: 10
Some tooltip text!
• 2 minutes to read
• 2 minutes to read
List available sale types
SearchEngine se;
se.addFields("SaleType", "SaleType_Id,name");
print(se.executeTextTable());
Check if a sale is connected to a guide
NSListAgent listAgent;
NSSaleAgent saleAgent;
NSSaleEntity sale = saleAgent.GetSaleEntity(4);
Integer saleTypeId = sale.GetSaleType().GetId();
NSSaleTypeEntity type = listAgent.GetSaleTypeEntity(saleTypeId);
if (type.GetHasGuide()) {
printLine("This sale has a guide!");
}
else {
printLine("This sale does not have a guide.");
}
Check if a contact has open sales
Bool hasOpenSales(Integer contactId) {
NSSaleAgent saleAgent;
DateTime from;
DateTime to;
NSSaleSummary summary = saleAgent.GetSummaryByContact(contactId, from.addDay(-30), to);
return summary.GetOpen() > 0;
}
print(hasOpenSales(2).toString());
Get sales for associate
To call GetSaleList()
, we need to create the list of sale IDs 1st.
String associateId = "5";
Integer[] saleIds;
SearchEngine se;
se.addField("sale.sale_id");
se.addCriteria("sale.associate_id", "OperatorEquals", associateId,"OperatorAnd", 1);
se.execute();
while (!se.eof()) {
saleIds.pushBack(se.getField(0).toInteger());
se.next();
}
NSSaleAgent saleAgent;
NSSale[] saleList = saleAgent.GetSaleList(saleIds);
Get next due date for a given sale
Integer saleId = 1;
NSSaleAgent saleAgent;
DateTime due = saleAgent.GetNextDueDate(saleId);
printLine("This sale is due " + due.toString());
Get the n most urgent open sales
DateTime now;
Integer[] saleIds;
SearchEngine se;
se.addField("sale.sale_id");
se.addCriteria("sale.status", "OperatorEqual", "1","OperatorAnd", 1);
se.addCriteria("sale.sale", "OperatorLt", now.toString(), "OperatorAnd", 1);
se.addOrder("sale.saledate", false);
se.setLimit(10);
se.execute();
while (!se.eof()) {
saleIds.pushBack(se.getField(0).toInteger());
se.next();
}
NSSaleAgent saleAgent;
NSSale[] saleList = saleAgent.GetSaleList(saleIds);
Get the n potentially largest open sales
String amount = "100.0";
Integer[] saleIds;
SearchEngine se;
se.addField("sale.sale_id");
se.addCriteria("sale.amount", "OperatorGt", amount,"OperatorAnd", 1);
se.addCriteria("sale.status", "OperatorEqual", "1","OperatorAnd", 1);
se.addOrder("sale.amount", false);
se.setLimit(10);
se.execute();
while (!se.eof()) {
saleIds.pushBack(se.getField(0).toInteger());
se.next();
}
NSSaleAgent saleAgent;
NSSale[] saleList = saleAgent.GetSaleList(saleIds);