Skip to Content

Expense Report - Approve by ABSL Script

Hi All,

I need to approve the Expense report via ABSL script.

Is it possible? I already succeed with TimeSheet. So that I tried with an expense. But I am getting an error as "Process Instance not found for BO .ID".

Scenario: Expense record is coming from web service (Third Party SW).In ByD, This record should save with Status as "Approved".

Please help me to solve this problem? Otherwise is there any alternative solution to fulfill this requirement?

var description;
var IsCreatedByWebservice = false;

//This blog is indicate that the record is coming form Webservice
if (!this.Description.IsInitial())
{
	description = this.Description;
	var findSeprator = description.Find("~WS~");
	var findSepratorString = findSeprator.ToString();
	if (findSepratorString != "-1")
	{
		IsCreatedByWebservice = true;
		this.Description = description.Substring(findSeprator + 4);
	}
}

if (IsCreatedByWebservice)
{
  if(this.Status.SubmissionStatusCode != "2")
  {
    this.Submit();
  }
  if(this.Status.AuditStatusCode != "2" && this.Status.AuditStatusCode != "5" )
  {
    this.AcceptExpenseReport();
  }
  if(this.Status.ApprovalStatusCode == "3")
  {
   this.Approve("testing");
  }
}
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

3 Answers

  • Oct 20, 2016 at 02:57 AM

    Hi Sankaran,

    It looks like the current Expense instance doesn't have associated approval instance.

    So, you could retrieve and check if Approval exists on the current instance before calling Approve.

    Thanks, Pradeep.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Pradeep,

      Thanks for your reply. But as soon as I submit the expense, the status will be changed to "Approval is pending".

      Without Approval instance how the status changed like this? and as you said, Where should I check approval instance (BO)?

      If it is wrong, please correct it.

      Regards,

      Sankaran A.

  • Oct 20, 2016 at 08:49 AM

    Hello Sankan,

    You can not set the value of a status variable direct in a BeforeSave snippet.

    This can only be done in a Status Action.

    HTH,
    Horst

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 21, 2016 at 02:51 AM

    Hi Sankaran,

    If the status is getting changed, then there should be no issue.

    Thanks, Pradeep.

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Pradeep

      We can't change status directly . The field doesn't have PSM release. That is the reason , I'm trying to trigger all the actions.

      Thanks

      Sankaran