Auto-approval of purchase order workflow for net amount field value same or less

Hi,

Auto-approval of purchase order workflow for net amount field if the value is same or less.I have given condition for the purchase order workflow but I am not able to give the Purchase order line.NetAmount field as value.

Please see the below screenshots for your reference.suggest me the solution.

What are trying to do? Which of the two fields you are trying to compare?

Hi Kranthi,
I want compare with the Net Amount field.
I want to auto approve the purchase order through Net amount field with less than and equal condition.

I am not able to see the purchase order line .Net Amount in drop down. Please suggest me the solution.

Hi Kranthi,
I have added the NetAmount field in dropdown by creating the parm method as "parmPurchLineAmount " in “PurchTableDocument” class.but getting errror like “workflow stopped”.How to resolve the error.

What is the total error? Have you generated the IL after code change?
Can you show us the code?

Hi,
If i edit the purchase order workflow then getting error like “An unexpected error has occurred while opening the workflow. See the event log on the AOS and contact your system administrator to resolve the issue”.
I have generated the full CIL but again getting above error.

I have created the parm method as “parmPurchLineAmount” in “WorkflowDocument” class.

public PurchLineAmount parmPurchLineAmount(tableId _tableId, RecId _recId)
{
PurchLine purchLine;
;
select LineAmount from purchLine where purchLine.RecId == _recId;
return purchLine.LineAmount;
}
Suggest me the possible solution.

Shouldn’t it be having three parameters. (CompanyId _companyId, TableId _tableId, RecId _recId)

Hi Kranthi,
I have written code as you suggested.Now error is not showing for one company.but auto approve is not working.Can you tell me what i am missing.

public PurchLineAmount parmLineAmount(CompanyId _companyId,TableId _tableId, RecId _recId)
{
PurchLine purchLine;
;
select LineAmount from purchLine where purchLine.RecId == _recId;
return purchLine.LineAmount;
}

See the below screenshots for your reference.

Above error is showing for other company…how to resolve the error in other company.

In which class you have written this method? What do you want this method to do?

I have written this method in “PurchTableDocument” class .This method is to display the purchline net amount field as label in workflow automatic Expression drop down.

PurchLines.NetAmount <= PurchLines.NetAmount → Is this what you are expecting? If so why do you want to compare the same field value? I am not clear on purpose of creating this condition.

Hi kranthi,

Yes…your correct.

If Po line unit price or qty increased or decreased then obliviously net amount value is automatically changes.If the value is increased then it auto approve Po workflow otherwise its ask for manual approval.

Comparing the same field will not work in that case, you have to check the previous version of purch line and current purch line value.
Are you using the line level workflow?

Hi kranthi,
I am using purch order level workflow.
How to check the previous version of purch line and current purch line value.
Can you give me the sample to code.

PO has the versioning capability. technet.microsoft.com/…/hh208627.aspx
This uses \Data Dictionary\Views\PurchLineAllVersions. Try using this view instead of PurchLine.
Also the ReciD in that method (parmPurchLineAmount) is related to PurchTable.Recid.

Hi Kranthi,

public PurchLineAmount parmLineAmount(CompanyId _companyId,TableId _tableId, RecId _recId)
{
PurchLineAllVersions PurchLineAllVersions;
;
this.getPurchTable(_recId);
select LineAmount from PurchLineAllVersions where PurchLineAllVersions.RecId == purchTable.RecId;
return PurchLineAllVersions.LineAmount;
}

I am not able to debug this method.How to enable the debugger for this method.
I have code like but not working as per requirement. Suggest me the solution.

You have to use the visual studio for debugging.
PurchLineAllVersions.RecId == purchTable.RecId; this condition is not correct.
There can be multiple lines for one purchase order, in that case which purchase line do you want to check?

I have debugged code but purchtable recid is not present in the view so it return the zero as line amount.
Please suggest me if increased po line net amount value then it ask for manual approve else it ask for auto approve.

You haven’t answered my question. In case of multiple lines, i would assume you will check all the line and if any one of the line has the increases net amount value then it goes to manual approval.
If so, you need to loop through the records in PurchLineHistory table. For that you need PurchTableHistory record. Form the purchTable you can get the PurchTableHistroty.

Hi Kranthi,
I want to check if any one of the line net amount is increased then it should goes for manual approve of purchase order.
As per your suggestion written code like.

public PurchLineAmount parmLineAmount(CompanyId _companyId,TableId _tableId, RecId _recId)
{
PurchLineAllVersions PurchLineAllVersions;
PurchTableHistory PurchTableHistory;
PurchLineHistory PurchLineHistory;
PurchLineAmount lineamount;
;
this.getPurchTable(_recId);

while select PurchLineHistory join PurchTableHistory
where PurchLineHistory.PurchId == PurchTableHistory.PurchId
&& PurchTableHistory.PurchId == purchTable.PurchId
{
select LineAmount from PurchLineAllVersions where PurchLineAllVersions.RecId == PurchLineHistory.RecId;
lineamount = PurchLineAllVersions.LineAmount;
}
return lineamount;
}