UBAQ Reject Requisition No Respone

Dear Sir,
Would like to seek for help on my code for UBaq on update the Reject Requisition, I has create a code in BPM base update but there’s still no any response and no any error prompt, is there some one have this experience kind to advise and share?

//var context = Ice.Services.ContextFactory.CreateContext<ErpContext>();
Erp.Contracts.ReqSvcContract ReqSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReqSvcContract>(Db);
Erp.Tablesets.ReqTableset ReqTS = new Erp.Tablesets.ReqTableset();

int iReqNum = (int)queryResultDataset.Results[0]["Calculated_iReqNum"];
string iCurrDispatcher = (string)queryResultDataset.Results[0]["Calculated_iCurrDispatcher"];
string iRequestor = (string)queryResultDataset.Results[0]["Calculated_iRequestor"];
Guid refSysRowID = new Guid("00000000-0000-0000-0000-000000000000");
bool outBool, c, d;
string a, b;

using (var txscope = IceDataContext.CreateDefaultTransactionScope())
{

  ReqTS = ReqSvc.GetByID(iReqNum); 
  ReqSvc.RDMenuFlags(iReqNum, iCurrDispatcher, out c, out d);  
  ReqSvc.GetReqLogList("ReqNum = '" + Convert.ToString(iReqNum) + "'", 100, 1, out c); 
  ReqSvc.CheckToDo(iCurrDispatcher);  
  if (ReqTS.ReqHead.Count > 0)
  {

    ReqTS.ReqHead[0].ReqNum = iReqNum;
    ReqTS.ReqHead[0].NextActionDesc = "Reject Requisition";
    ReqTS.ReqHead[0].NextDispatcherID = iRequestor;
    ReqTS.ReqHead[0].StatusType = "R";
    ReqTS.ReqHead[0].ReplyOption = "R";
    ReqTS.ReqHead[0].ReqUserId = iCurrDispatcher;
    //ReqTS.ReqHead[0].RowMod = "U";
  } 
  ReqSvc.Update(ref ReqTS);  
  ReqSvc.CheckToDo(iCurrDispatcher); 
  ReqSvc.RDMenuFlags(iReqNum, iCurrDispatcher, out c, out d);  
  ReqSvc.GetReqLogList("ReqNum = '" + Convert.ToString(iReqNum) + "'", 100, 1, out c); 


  Db.Validate();
  txscope.Complete();
}

Could you back up and explain in more detail what you are wanting to do?

Just perusing the code, there are many concerns.

  • You have a transaction scope you likely don’t need.
  • You have a Db.Validate in there, when you are not editing the Db context.
  • You are not selecting the updated row(s)
  • You have extra BPM calls you likely don’t need.

Sorry for the long list, but if you could back up we’ll see if we can get you straight.

Hi sorry maybe I can elaborate detail, my mission is using the UBaq as input for requisition number, requestor and current dispatcher as input parameter, then I create BPM base with the custom code to execute the task to reject the dispatched Requisition.

Erp.Contracts.ReqSvcContract ReqSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReqSvcContract>(Db);
Erp.Tablesets.ReqTableset ReqTS = new Erp.Tablesets.ReqTableset();

int iReqNum = (int)queryResultDataset.Results[0]["Calculated_iReqNum"];
string iCurrDispatcher = (string)queryResultDataset.Results[0]["Calculated_iCurrDispatcher"];
string iRequestor = (string)queryResultDataset.Results[0]["Calculated_iRequestor"];
Guid refSysRowID = new Guid("00000000-0000-0000-0000-000000000000");
bool outBool, c, d;
string a, b;

  ReqTS = ReqSvc.GetByID(iReqNum); 
  ReqSvc.RDMenuFlags(iReqNum, iCurrDispatcher, out c, out d);  
  ReqSvc.GetReqLogList("ReqNum = '" + Convert.ToString(iReqNum) + "'", 100, 1, out c); 
  ReqSvc.CheckToDo(iCurrDispatcher);  
  if (ReqTS.ReqHead.Count > 0)
  {

    ReqTS.ReqHead[0].ReqNum = iReqNum;
    ReqTS.ReqHead[0].NextActionDesc = "Reject Requisition";
    ReqTS.ReqHead[0].NextDispatcherID = iRequestor;
    ReqTS.ReqHead[0].NextNote = "Reject PR";
    ReqTS.ReqHead[0].ReplyOption = "R";
    ReqTS.ReqHead[0].ReqUserId = iCurrDispatcher;
    ReqTS.ReqHead[0].RowMod = "U";
  } 
  ReqSvc.Update(ref ReqTS);  
  ReqSvc.CheckToDo(iCurrDispatcher); 
  ReqSvc.RDMenuFlags(iReqNum, iCurrDispatcher, out c, out d);  
  ReqSvc.GetReqLogList("ReqNum = '" + Convert.ToString(iReqNum) + "'", 100, 1, out c); 

I’m not familiar with that BO, but the way you have that structured, you are only operating on the first result in the BAQ, which might not even be the correct row if you have only one, because you need to choose the updated row.

You still have stuff in there that likely does nothing as well.

This was done in notepad, so no checking, but this should probably be closer to what you need.

Erp.Contracts.ReqSvcContract ReqSvc = Ice.Assemblies.ServiceRenderer.GetService<Erp.Contracts.ReqSvcContract>(Db);

//Chose rows that are updated
var updatedRows = queryResultDataset.Results.Where(x => x.RowMod == "U");

//Loop through updated rows
foreach(var uRow in updatedRows)
{
    int    iReqNum         = uRow["Calculated_iReqNum"];
    string iCurrDispatcher = uRow["Calculated_iCurrDispatcher"];
    string iRequestor      = uRow["Calculated_iRequestor"];

    Erp.Tablesets.ReqTableset ReqTS = ReqSvc.GetByID(iReqNum); 

    if (ReqTS.ReqHead.Count > 0)
    {
        ReqTS.ReqHead[0].ReqNum           = iReqNum;
        ReqTS.ReqHead[0].NextActionDesc   = "Reject Requisition";
        ReqTS.ReqHead[0].NextDispatcherID = iRequestor;
        ReqTS.ReqHead[0].NextNote         = "Reject PR";
        ReqTS.ReqHead[0].ReplyOption      = "R";
        ReqTS.ReqHead[0].ReqUserId        = iCurrDispatcher;
        ReqTS.ReqHead[0].RowMod           = "U";
    }
 
    ReqSvc.Update(ref ReqTS);  
}

1 Like

Thanks @klincecum , you are correct, after GetByID it return 2 rows in tableset, which i notice in during tracing option, and the standard system has chosen the second row to update instead the first, is that possible to choose after GetByID tableset, but your idea is more closer as what i need, i will try out, thanks!

1 Like

Would the standard BAQ update not work?

Sorry for my late response, yup the standard wont work, it can be execute without error but nothing happen on the rows update, I also have no idea, for the rest on PR approval BPM which work perfectly and I has event convert in function to call in API.
The trace route has follow all the method been call, just not understand why the row still unable to change, just i notice the row update on second rows after GetByID.

1 Like