Fetching CustId on SalesEditLine form

I have a requirement in which when i press the posting or the confirmation button on Sales Order , the salesEditLine form should be open with a message "The preferred method of communication is ".

I wrote the code in SalesEditLine (form) run method , now every time i open the form a message is displayed but i am not able to retrieve value from custtable. How can i achieve this ?

Can you be more specific? For example, are you trying to get the active SalesTable record from Sales order form and you don’t know how to do it? Or what else is the problem?

Suppose i have a record selected of which i want to go for posting/confirmation in salesTable , i want to display the value of my customized field before the form opens and the value is from CustTable , my code do not catch the record id so it shows blank message instead of displaying the related field value

Yes, I know that your code doesn’t work, but I don’t know what exactly you’re trying to do with it and where it goes wrong. It’s impossible to tell you where you have a bug if you don’t tell us anything about your code.

The following code has been added in run method in salesEditLine form

Box::info(strfmt(“Customer’s preferred method of communication is %1”,custtable.smylHexPrefComm));

Required output : Customer’s preferred method of communication is < retireved value from Custtable>

My output : Customer’s preferred method of communication is

This piece of code shows nothing relevant - the problem is in how you fill (don’t fill) custTable variable (which you still neither explained nor showed).

i haven’t wrote anything else , this is the only line i have added in the run method , here is the complete code :

void run()

{

SalesUpdate recommendedQty;

SysDictEnum salesUpdateEnum = new SysDictEnum(enumnum(SalesUpdate));

BoxFormOnce box;

custtable custtable;

;

super();

salesEditLinesForm.setupSumByControl(sumBy, salesParmUpdate.SpecQty, salesParmUpdate.SumBy);

if (salesParmUpdate.ParmId)

{

element.lock();

if (salesParmUpdate.LateSelection)

{

if (salesParmUpdate.LateSelectionQuery)

salesFormLetter.queryChooseLines(new QueryRun(salesParmUpdate.LateSelectionQuery));

element.initQuery();

}

salesFormLetter.setSalesEditLinesDataSource(salesParmTable_ds);

print_Combo.selection (salesFormLetter.printout());

printFormletter.value (salesFormLetter.printFormLetter());

printCODLabelChoice = (salesFormLetter.printCODLabel());

printCallTagChoice = (salesFormLetter.printFreightSlip());

printShippingLabelChoice = (salesFormLetter.printShippingLabel());

usePrintManagement.value (salesFormLetter.usePrintManagement());

this.setFieldAccess();

reArrangeNow = (salesFormLetter.reArrangeNow());

editLinesChanged = (salesFormLetter.editLinesChanged());

custAccountInQuery = (salesFormLetter.custAccountInQuery());

invoiceAccountInQuery = (salesFormLetter.invoiceAccountInQuery());

element.sumByChanged(true);

if (documentStatus == DocumentStatus::Invoice)

{

if (salesFormLetter.salesTable())

{

if (salesFormLetter.defaultGiroType())

salesParmUpdate.GiroType = PaymentStubInclAll::All;

else

salesParmUpdate.GiroType = salesFormLetter.giroType() + 0;

}

else

{

salesParmUpdate.GiroType = CustFormletterParameters::find().GiroOnInvoice + 0;

}

salesFormLetter.giroType (salesParmUpdate.GiroType + 0);

salesFormLetter.defaultGiroType (salesParmUpdate.GiroType == PaymentStubInclAll::All);

salesParmUpdate_ds.refresh();

}

element.design().caption (salesEditLinesForm.editingCaption());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, RespiteDate)).visible(salesEditLinesForm.respiteDate());

salesParmTable_TransDate.label (salesEditLinesForm.transDateCaption());

printFormletter.label (salesEditLinesForm.formLetterCaption());

buttonPrintFormletter.text (salesEditLinesForm.formLetterButtonCaption());

buttonPrintFormletterCopy.text (salesEditLinesForm.formLetterButtonCaptionCopy());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, Storno)).visible(salesEditLinesForm.correct());

warehouseManagement.visible (salesEditLinesForm.wmsOrder());

salesParmTable_ds.object(fieldnum(SalesParmTable, FixedDueDate)).visible (salesEditLinesForm.fixedDueDate());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, Reserve)).visible (salesEditLinesForm.reserve());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, Reserve)).allowEdit (salesEditLinesForm.editReserve());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, Reserve)).skip (!salesEditLinesForm.editReserve());

salesParmLine_ds.object(fieldnum(SalesParmLine, Closed)).visible (salesEditLinesForm.close());

salesParmUpdate_ds.object(fieldnum(SalesParmUpdate, CreditRemaining)).visible(salesEditLinesForm.creditRemaining());

salesParmLine_ds.object(fieldnum(SalesParmLine, RemainAfter)).allowEdit (salesEditLinesForm.editRemainAfter());

salesParmLine_ds.object(fieldnum(SalesParmLine, RemainAfter)).skip (!salesEditLinesForm.editRemainAfter());

buttonPaymentSched.visible (salesEditLinesForm.paymentSched());

buttonPaymentSched.enabled (salesFormLetter.salesTable().PaymentSched != ‘’);

buttonSelectJournal.visible (salesEditLinesForm.selectJournalButton());

buttonSelectJournal.enabled (salesParmUpdate.SpecQty == SalesUpdate::PackingSlip);

updateNow.enabled (salesFormLetter.enableUpdateNowField());

print_Combo.enabled (!salesFormLetter.proforma());

salesParmTable_inventSiteId.visible (salesParmUpdate.SplitSite == NoYes::Yes);

choose.visible (salesEditLinesForm.choose());

sumBy.visible (salesEditLinesForm.sumBy());

creditMax.visible (salesEditLinesForm.creditMax());

buttonSalesTotals.visible (salesEditLinesForm.salesTotals());

salesParmTable_ds.allowCreate (salesEditLinesForm.allowCreate_ParmTable() && !salesParmUpdate.LateSelection);

salesParmLine_ds.allowCreate (salesEditLinesForm.allowCreate_ParmLine() && !salesParmUpdate.LateSelection);

salesParmTable_ds.object(fieldnum(SalesParmTable, ProjId)).visible (salesEditLinesForm.projId());

salesParmTable_ds.object(fieldnum(SalesParmTable, CustBankAccountId)).visible (salesEditLinesForm.custBankAccountId());

salesParmTable_ds.object(fieldnum(SalesParmTable, CustBankAccountId)).allowEdit (salesEditLinesForm.custBankAccountIdAllowEdit());

salesParmTable_ds.object(fieldnum(SalesParmTable, CustBankAccountId)).skip (!salesEditLinesForm.custBankAccountIdAllowEdit());

qtyToPickInSalesUnit.visible (salesEditLinesForm.qtyToPickInSalesUnit());

switch (documentStatus)

{

case DocumentStatus::PackingSlip :

groupShipments.visible(salesFormLetter.useShippingStat());

break;

case DocumentStatus::Invoice :

groupShipments.visible(salesFormLetter.useShippingStat());

break;

default :

groupShipments.visible(false);

buttonSalesShippingLine.visible(false);

}

shippingEnabled = buttonSalesShippingLine.visible();

if (salesFormLetter.showQueryForm() && !salesFormLetter.createFromHistory())

buttonSalesShippingLine.enabled(false);

tabSalesParmSubLine.visible(salesEditLinesForm.subLine());

element.unLock();

if (SalesParameters::find().PromptQty && !salesFormLetter.lockSalesUpdateField())

{

recommendedQty = salesFormLetter.recommendedSpecQty();

if(recommendedQty!=specQty.selection())

{

boxFormOnceIsActive = true;

box = BoxFormOnce::construct();

box.parmDialogBoxType(DialogBoxType::YesNoBox);

box.parmDialogButton(DialogButton::Yes);

box.parmTitle("@SYS59372");

box.parmText(strfmt("@SYS102340", salesUpdateEnum.index2Name(specQty.selection()), salesUpdateEnum.index2Name(recommendedQty)));

box.parmOwner(new SysDictClass(classidget(salesEditLinesForm)).name());

if(box.prompt() == DialogButton::Yes)

{

specQty.selection(recommendedQty);

specQty.selectionChange();

}

boxFormOnceIsActive = false;

}

}

}

element.setFieldAccess();

element.specQtyChanged();

editLinesChanged = false;

//modified by Shubham Sharma

//Custtable::find(custtable.smylHexPrefComm);

//custtable = element.args().record();

Box::info(strfmt(“Customer’s preferred method of communication is %1”,custtable.smylHexPrefComm));

}

If you never fill a variable, you shouldn’t be surprised that it’s empty. You have to fill custTable in some way.

For example, you can use find SalesParmTable, use its SalesId to find the order and get the customer from there.

Finally found the solution of this issue

Box::info(strfmt(“Customer’s preferred method of communication is %1”,CustTable::find(SalesParmTable.CustAccount).smylHexPrefComm));

Heh, I didn’t check if CustTable isn’t copied directly to SalesParmTable. So my solution was more complicated than necessary, but at least I managed to show you the key part: SalesParmTable.