Workid count summary sales order form

i am created four customized fieds in total workids, totalsopen workids, totalclosed workids, total cancelled workids. and add in salestablelistpage form . but how to count and update the workids in salesorder form .give me suggestions. tell me where i have write the code.

The details of the WORK IDs and their status against the sales order will be obtained in the ALL WORK form in warehouse management.

So you have added these fields to salesTable? if so, you need to update those fields whenever new work record gets created or the work status gets updated.

\Data Dictionary\Tables\WHSWorkTable\Methods\insert

\Data Dictionary\Tables\WHSWorkTable\Methods\update

i am written this below code but its not working. how to the write the logic .

WHSWorkTable wHSWorkTable;
SalesTable salesTable;
select count(WorkId)from wHSWorkTable
where wHSWorkTable.OrderNum == “SO19/012345”
//&& wHSWorkTable.WorkStatus == WHSWorkStatus::Open
&& wHSWorkTable.WorkStatus == WHSWorkStatus::Cancelled;
select forUpdate salesTable
join wHSWorkTable where
wHSWorkTable.OrderNum = salesTable.SalesId;
{
ttsBegin;
salesTable.TotalNumberOfCancelledWorkIDs = wHSWorkTable.WorkId;

salesTable.update();

ttsCommit;

}

Where you have written this code?

You are not saying which salesTable record you want to update. You are just using the join. See below example,

select forUpdate salesTable
where salesTable.SalesId == “SO19/012345”;

if (salesTable.RecId)

{
ttsBegin;
salesTable.TotalNumberOfCancelledWorkIDs = wHSWorkTable.WorkId;

salesTable.doUpdate();

ttsCommit;

}

Also include workTransType in the where clause.

I am written code in whs worktable update method. My requirement is update the total number of workids, open workids, closed workids and cancelled workids in salestablelistpage. How to write the code. Send me code sir.

If you are writing in update then why are you hard coding sales Id?

if (this.WorkTransType == WHSWorkTransType::Sales)
{
    select count(WorkId)from wHSWorkTable
        where wHSWorkTable.OrderNum == this.OrderNum
        && wHSWorkTable.WorkTransType == WHSWorkTransType::Sales
        && wHSWorkTable.WorkStatus == WHSWorkStatus::Cancelled;

    salesTable= SalesTable::find(this.OrderNum, true);

    if (salesTable.RecId)
    {
        ttsBegin;
        salesTable.TotalNumberOfCancelledWorkIDs = wHSWorkTable.WorkId;
        salesTable.doUpdate();
        ttsCommit;
     }
}