Thanks Jack and wonderful folks here for discussing this.
I agree with Jack's suggestion to Configure query as a SQL Data Adapter, using custom variables(Using BRString() maybe where necessary, then use BRApi.Dashboards.Process.GetAdoDataSetForAdapter to execute it from a rule as a workaround.
FYI.
The two queries that worked both in data adapter and code are:
Query:
Select XFW_PLP_Register.RegisterID,
XFW_PLP_Register.RegisterIDInstance,
XFW_PLP_Register.WFProfileName,
XFW_PLP_Register.WFScenarioName,
XFW_PLP_Register.WFTimeName,
COALESCE(NULLIF(X.JobTitle,''), XFW_PLP_Register.JobTitle) JobTitle ,
COALESCE(NULLIF(X.LastName,''), XFW_PLP_Register.LastName) LastName,
COALESCE(NULLIF(X.FirstName,''), XFW_PLP_Register.FirstName) FirstName ,
COALESCE(X.Wage,XFW_PLP_Register.Wage) Wage ,
COALESCE(X.Bonus, XFW_PLP_Register.Bonus) Bonus,
COALESCE(X.FTE, XFW_PLP_Register.FTE) FTE,
COALESCE(X.GradeLevel, XFW_PLP_Register.GradeLevel) GradeLevel ,
COALESCE(XFW_PLP_Register.Status, X.Status) Status ,
COALESCE(X.HireDate, XFW_PLP_Register.HireDate) HireDate ,
COALESCE(X.HirePeriod, XFW_PLP_Register.HirePeriod) HirePeriod ,
COALESCE(X.TermDate, XFW_PLP_Register.TermDate) TermDate,
COALESCE(X.TermPeriod, XFW_PLP_Register.TermPeriod) TermPeriod ,
COALESCE(X.BirthDate, XFW_PLP_Register.BirthDate) BirthDate ,
DATEDIFF(month, '1/1/2024', IIF(CONVERT(varchar,COALESCE(NULLIF(X.TermDate,'1/1/1900 12:00:00 AM'), XFW_PLP_Register.TermDate),101) = '1/1/1900','1/1/3999',CONVERT(varchar,COALESCE(NULLIF(X.TermDate,'1/1/1900 12:00:00 AM'), XFW_PLP_Register.TermDate),101))) +1 As OutPeriod,
COALESCE(X.OutCode, XFW_PLP_Register.OutCode) OutCode ,
DATEDIFF(month, '1/1/2024',IIF(CONVERT(varchar,COALESCE(NULLIF(X.DCode1,'1/1/1900 12:00:00 AM'), XFW_PLP_Register.DCode1),101) = '1/1/1900','1/1/3999',CONVERT(varchar,COALESCE(NULLIF(X.DCode1,'1/1/1900 12:00:00 AM'), XFW_PLP_Register.DCode1),101))) +1 As InPeriod,
COALESCE(X.InCode, XFW_PLP_Register.InCode) InCode ,
COALESCE(NULLIF(X.Entity,'None'), XFW_PLP_Register.Entity) Entity,
COALESCE(NULLIF(X.Code1,''),XFW_PLP_Register.Code1) Code1,
COALESCE(NULLIF(X.Code2,''), XFW_PLP_Register.Code2) Code2,
COALESCE(NULLIF(X.Code3,''), XFW_PLP_Register.Code3) Code3 ,
COALESCE(NULLIF(X.Code4,''), XFW_PLP_Register.Code4) Code4,
COALESCE(NULLIF(X.Code5,''), XFW_PLP_Register.Code5) Code5 ,
COALESCE(NULLIF(X.Code6,''), XFW_PLP_Register.Code6) Code6 ,
COALESCE(NULLIF(X.Code7,''), XFW_PLP_Register.Code7) Code7,
COALESCE(NULLIF(X.Code8,''), XFW_PLP_Register.Code8) Code8 ,
COALESCE(NULLIF(X.Code9,''), XFW_PLP_Register.Code9) Code9 ,
COALESCE(NULLIF(X.Code10,''), XFW_PLP_Register.Code10) Code10,
COALESCE(NULLIF(X.Code11,''), XFW_PLP_Register.Code11) Code11,
COALESCE(NULLIF(X.Code12,''), XFW_PLP_Register.Code12) Code12 ,
COALESCE(X.NCode1, XFW_PLP_Register.NCode1) NCode1,
COALESCE(X.NCode2, XFW_PLP_Register.NCode2) NCode2,
COALESCE(X.NCode3, XFW_PLP_Register.NCode3) NCode3 ,
COALESCE(X.NCode4, XFW_PLP_Register.NCode4) NCode4 ,
COALESCE(X.NCode5, XFW_PLP_Register.NCode5) NCode5 ,
COALESCE(X.NCode6, XFW_PLP_Register.NCode6) NCode6 ,
COALESCE(X.NCode7, XFW_PLP_Register.NCode7) NCode7,
COALESCE(X.NCode8, XFW_PLP_Register.NCode8) NCode8 ,
COALESCE(X.DCode1, XFW_PLP_Register.DCode1) DCode1,
COALESCE(X.DCode2, XFW_PLP_Register.DCode2) DCode2,
COALESCE(X.DCode3, XFW_PLP_Register.DCode3) DCode3,
COALESCE(X.DCode4, XFW_PLP_Register.DCode4) DCode4,
COALESCE(NULLIF(X.Annot1,''), XFW_PLP_Register.Annot1) Annot1,
COALESCE(NULLIF(X.Annot2,''),XFW_PLP_Register.Annot2) Annot2,
XFW_PLP_CalcPlanDetail.CalcPlanDetailID As DetailID,
XFW_PLP_CalcPlanDetail.FKClassID,
XFW_PLP_CalcPlanDetail.Description,
XFW_PLP_CalcPlanDetail.WeightOrCount,
XFW_PLP_CalcPlanDetail.PeriodDivisor,
XFW_PLP_CalcPlanDetail.PeriodFilter,
XFW_PLP_CalcPlanDetail.Condition,
XFW_PLP_CalcPlanDetail.EntityOverride,
XFW_PLP_CalcPlanDetail.FlowOverride,
XFW_PLP_CalcPlanDetail.ICOverride,
XFW_PLP_CalcPlanDetail.UD1Override,
XFW_PLP_CalcPlanDetail.UD2Override,
XFW_PLP_CalcPlanDetail.UD3Override,
XFW_PLP_CalcPlanDetail.UD4Override,
XFW_PLP_CalcPlanDetail.UD5Override,
XFW_PLP_CalcPlanDetail.UD6Override,
XFW_PLP_CalcPlanDetail.UD7Override,
XFW_PLP_CalcPlanDetail.UD8Override,
XFW_PLP_CalcPlanDetail.Sequence
From
XFW_PLP_Register
CROSS Join XFW_PLP_CalcPlanDetail
left outer Join (Select * from XFW_PLP_Register where Status = 'OneStream' and
WFProfileName = 'Workforce Norway.01 Employee Register'
And WFScenarioName = 'BudV1'
And WFTimeName = '2024') X
On X.RegisterID = XFW_PLP_Register.RegisterID
Where (
XFW_PLP_Register.WFProfileName = 'Workforce Norway.01 Employee Register'
And XFW_PLP_Register.WFScenarioName = 'BudV1'
And XFW_PLP_Register.WFTimeName = '2024'
And XFW_PLP_CalcPlanDetail.FKCalcPlanID = '15_ACTIVE_HUNGARY'
And XFW_PLP_CalcPlanDetail.FKWFProfileName = 'PlanTemplate'
And XFW_PLP_CalcPlanDetail.FKWFScenarioName = 'PlanTemplate'
And XFW_PLP_CalcPlanDetail.FKWFTimeName = 'PlanTemplate'
)
Order By
XFW_PLP_Register.RegisterID, XFW_PLP_Register.RegisterIDInstance, XFW_PLP_CalcPlanDetail.CalcPlanDetailID, XFW_PLP_CalcPlanDetail.Sequence
Query2:
Select XFW_PLP_Register.RegisterID,
XFW_PLP_Register.RegisterIDInstance,
XFW_PLP_Register.WFProfileName,
XFW_PLP_Register.WFScenarioName,
XFW_PLP_Register.WFTimeName,
XFW_PLP_Register.JobTitle,
XFW_PLP_Register.LastName,
XFW_PLP_Register.FirstName,
XFW_PLP_Register.Wage,
XFW_PLP_Register.Bonus,
XFW_PLP_Register.FTE,
XFW_PLP_Register.GradeLevel,
XFW_PLP_Register.Status,
XFW_PLP_Register.HireDate,
XFW_PLP_Register.HirePeriod,
XFW_PLP_Register.TermDate,
XFW_PLP_Register.TermPeriod,
XFW_PLP_Register.BirthDate,
DATEDIFF(month, '1/1/2024', IIF(CONVERT(varchar,(XFW_PLP_Register.TermDate),101) = '1/1/1900','1/1/3999',CONVERT(varchar,XFW_PLP_Register.TermDate,101))) +1 As OutPeriod,
XFW_PLP_Register.OutCode,
DATEDIFF(month, '1/1/2024', IIF(CONVERT(varchar,(XFW_PLP_Register.DCode1),101) = '1/1/1900','1/1/3999',CONVERT(varchar,XFW_PLP_Register.DCode1,101))) +1 As InPeriod,
XFW_PLP_Register.InCode,
XFW_PLP_Register.Entity,
XFW_PLP_Register.Code1,
XFW_PLP_Register.Code2,
XFW_PLP_Register.Code3,
XFW_PLP_Register.Code4,
XFW_PLP_Register.Code5,
XFW_PLP_Register.Code6,
XFW_PLP_Register.Code7,
XFW_PLP_Register.Code8,
XFW_PLP_Register.Code9,
XFW_PLP_Register.Code10,
XFW_PLP_Register.Code11,
XFW_PLP_Register.Code12,
XFW_PLP_Register.NCode1,
XFW_PLP_Register.NCode2,
XFW_PLP_Register.NCode3,
XFW_PLP_Register.NCode4,
XFW_PLP_Register.NCode5,
XFW_PLP_Register.NCode6,
XFW_PLP_Register.NCode7,
XFW_PLP_Register.NCode8,
XFW_PLP_Register.DCode1,
XFW_PLP_Register.DCode2,
XFW_PLP_Register.DCode3,
XFW_PLP_Register.DCode4,
XFW_PLP_Register.Annot1,
IIF(XFW_PLP_Register.Status = 'Workday', 'Workday', 'People Register') As Annot2,
XFW_PLP_CalcPlanDetail.CalcPlanDetailID As DetailID,
XFW_PLP_CalcPlanDetail.FKClassID,
XFW_PLP_CalcPlanDetail.Description,
XFW_PLP_CalcPlanDetail.WeightOrCount,
XFW_PLP_CalcPlanDetail.PeriodDivisor,
XFW_PLP_CalcPlanDetail.PeriodFilter,
XFW_PLP_CalcPlanDetail.Condition,
XFW_PLP_CalcPlanDetail.EntityOverride,
XFW_PLP_CalcPlanDetail.FlowOverride,
XFW_PLP_CalcPlanDetail.ICOverride,
XFW_PLP_CalcPlanDetail.UD1Override,
XFW_PLP_CalcPlanDetail.UD2Override,
XFW_PLP_CalcPlanDetail.UD3Override,
XFW_PLP_CalcPlanDetail.UD4Override,
XFW_PLP_CalcPlanDetail.UD5Override,
XFW_PLP_CalcPlanDetail.UD6Override,
XFW_PLP_CalcPlanDetail.UD7Override,
XFW_PLP_CalcPlanDetail.UD8Override,
XFW_PLP_CalcPlanDetail.Sequence
From
XFW_PLP_Register
CROSS Join XFW_PLP_CalcPlanDetail
Where (
XFW_PLP_Register.WFProfileName = 'Workforce UK.01 Employee Register'
And XFW_PLP_Register.WFScenarioName = 'BudV1'
And XFW_PLP_Register.WFTimeName = '2024'
And XFW_PLP_CalcPlanDetail.FKCalcPlanID = '01_ACTIVE_UK'
And XFW_PLP_CalcPlanDetail.FKWFProfileName = 'PlanTemplate'
And XFW_PLP_CalcPlanDetail.FKWFScenarioName = 'PlanTemplate'
And XFW_PLP_CalcPlanDetail.FKWFTimeName = 'PlanTemplate'
And (XFW_PLP_Register.Status ='Workday')
)
Order By
XFW_PLP_Register.RegisterID, XFW_PLP_Register.RegisterIDInstance, XFW_PLP_CalcPlanDetail.CalcPlanDetailID, XFW_PLP_CalcPlanDetail.Sequence
The Query which worked in the SQL Adapter but didn't work as expected is the mentioned at the Top.