public void initFromArgs(Args _args)
{
if(_args.record())
{
if(_args.record().TableId == tableNum(SalesQuotationLine))
{
quotationLine = _args.record();
}
else if(_args.record().TableId == tableNum(salesLine))
{
salesLine = _args.record();
}
else
{
throw error(Error::wrongUseOfFunction(funcName()));
}
}
}
public void run()
{
if(quotationLine)
{
XContract xContract = this.initXContract(quotationLine);
if(quotationLine.Field1)
{
Class1::send(quotationLine, xContract);
}
else
{
class2::send(quotationLine,xContract);
}
}
else if(salesLine)
{
XContract xContract = this.initXContract(null, salesLine);
if(salesLine.Field1)
{
Class1::send(salesLine, xContract);
}
else
{
Class2::send(salesLine, xContract);
}
}
}
public XContract initXContract(SalesQuotationLine _salesQuotationLine, SalesLine _salesLine = null)
{
XContract xContract = new XContract();
if(_salesQuotationLine && !_salesLine)
{
xContract.parmField1(_salesQuotationLine.Field1);
xContract.parmField2(_salesQuotationLine.Field2);
xContract.parmField3(_salesQuotationLine.Field3);
}
else if (_salesLine && !_salesQuotationLine)
{
xContract.parmField1(_salesLine.Field1);
xContract.parmField2(_salesLine.Field2);
xContract.parmField3(_salesLine.Field3);
}
return xContract;
}
SalesLine line;
fieldName2Id(line.TableId, fieldStr(SalesQuotationLine, ItemId));
Please fix your code before trying to test further changes. Common line = _salesQuotationLine ? _salesQuotationLine : _salesLine; //this errors
xContract.parmField1(fieldId2Name(line.TableId, fieldNum(line.TableId, Field1))); //this also errors
public XContract initXContract(Common _line)
{
XContract contract = new XContract();
contract.parmField1(_line.(fieldName2Id(_line.TableId, 'Field1'));
return contract;
}
public abstract class MyProcess
{
public void run()
{
if (this.shouldDoA())
{
this.sendA();
}
else
{
this.sendB();
}
}
private void sendA()
{
ClassA::send(this.line(), this.initContract());
}
private void sendB()
{
ClassB::send(this.line(), this.initContract());
}
protected abstract boolean shouldDoA();
{
}
protected abstract XContract initContract();
{
}
protected abstract Common line()
{
}
}
public MyProcessSalesLine extends MyProcess
{
SalesLine salesLine;
public static MyProcessSalesLine newFromRecord(SalesLine _salesLine)
{
MyProcessSalesLine myProcess = new MyProcessSalesLine();
myProcess.salesLine = _salesLine;
return myProcess;
}
protected Common line()
{
return salesLine;
}
protected boolean shouldDoA();
{
return salesLine.Field1;
}
protected XContract initContract();
{
return XContract::newFromSalesLine(salesLine);
}
}
​
Common line = _salesQuotationLine ? _salesQuotationLine : _salesLine; //this errors
xContract.parmField1(fieldId2Name(line.TableId, fieldNum(line.TableId, Field1))); //this also errors
​
Martin Dráb
512
Most Valuable Professional
Saalim Ansari
315
Adis
312
Super User 2025 Season 1