04-06-2023 01:11 PM
Hi,
We need to create an Auto Rec Rule for an Account Group that has to check if the child recs have data when the balance is zero for the Account Group and set as In Process or not Auto Rec.
I have try with expression |Balance| <>0, but with no success
Thanks for your time,
Regards
Solved! Go to Solution.
04-13-2023 06:51 PM - edited 04-13-2023 06:56 PM
Hi,
I create a Business Rule to solve this issue, in the expression add the next: |Balance|=XFBR(CustomAutoRec, groupID=|GroupID|, wtk=|Wtk|) passing to the BS the GroupID and the Workflow time ID in order to find the according child recs from the group then by an ApplicationQuery get the child recs balances from the app table 'XFW_RCM_ReconBalance'
Basic Logic XFBR
If args.FunctionName.XFEqualsIgnoreCase("CustomAutoRec") Then
Dim reconGroupID As String = args.NameValuePairs.XFGetValue("reconGroupID")
Dim wtk As String = args.NameValuePairs.XFGetValue("wtk")
'Define the SQL Statement
Dim sql As New System.Text.StringBuilder
sql.Append("SELECT Count(Balance) as Result FROM XFW_RCM_ReconBalance WHERE CAST(ReconGroupID AS char(36)) = '"& reconGroupID &"' and Wtk = '"& wtk &"' and Balance <> 0")
' sql.AddParameter("reconGroupID", reconGroupID)
' sql.AddParameter("wtk", wtk)
Dim dt As DataTable
Using dbConn As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
dt = BRApi.Database.ExecuteSql(dbConn, sql.toString(), True)
End Using
Dim result As String
Dim intRow As Integer = 0
If dt.Rows.Count > 0 Then
For intRow = 0 To dt.Rows.Count - 1
result = dt.Rows.Item(intRow).Item("Result")
Next intRow
Else
End If
Return result
End If
Regards
04-13-2023 06:51 PM - edited 04-13-2023 06:56 PM
Hi,
I create a Business Rule to solve this issue, in the expression add the next: |Balance|=XFBR(CustomAutoRec, groupID=|GroupID|, wtk=|Wtk|) passing to the BS the GroupID and the Workflow time ID in order to find the according child recs from the group then by an ApplicationQuery get the child recs balances from the app table 'XFW_RCM_ReconBalance'
Basic Logic XFBR
If args.FunctionName.XFEqualsIgnoreCase("CustomAutoRec") Then
Dim reconGroupID As String = args.NameValuePairs.XFGetValue("reconGroupID")
Dim wtk As String = args.NameValuePairs.XFGetValue("wtk")
'Define the SQL Statement
Dim sql As New System.Text.StringBuilder
sql.Append("SELECT Count(Balance) as Result FROM XFW_RCM_ReconBalance WHERE CAST(ReconGroupID AS char(36)) = '"& reconGroupID &"' and Wtk = '"& wtk &"' and Balance <> 0")
' sql.AddParameter("reconGroupID", reconGroupID)
' sql.AddParameter("wtk", wtk)
Dim dt As DataTable
Using dbConn As DbConnInfo = BRApi.Database.CreateApplicationDbConnInfo(si)
dt = BRApi.Database.ExecuteSql(dbConn, sql.toString(), True)
End Using
Dim result As String
Dim intRow As Integer = 0
If dt.Rows.Count > 0 Then
For intRow = 0 To dt.Rows.Count - 1
result = dt.Rows.Item(intRow).Item("Result")
Next intRow
Else
End If
Return result
End If
Regards