Skip to main content

Hello everyone,

 

Has anyone tried to use a Parameter in GI Grouping? I want to do something very simple. Using a Boolean Parameter I would like to add a grouping. To do so:

  • I have created a <checkbox> parameter called “GroupByTask” allowing users to check/uncheck on GI as a parameter.
  • I have added a grouping as “=IIf(GroupByTask]=True, ]PMTask.TaskCD], '')”, In the result grid I have the exact formula as a column.

When I run the inquiry I get an error saying “Must declare the scalar variable "@P0".” When I trace the query in SQL Profiler I see Acumatica generates a query that in Group By section has “CASE WHEN @P0 = 1 THEN EPMTask].1TaskCD] ELSE '' END” but the platform doesn’t declare any parameter and pass to the query for it.

 

Any idea how I can make this work?

@Gabriel Michaud

Not sure if is going to be of any use but below I have copied the query that platform generates.

SELECT SUM( aInnerQuery].CPMCostProjectionLine_usrHCLBudgetOriginalQty]) AS dPMCostProjectionLine_usrHCLBudgetOriginalQty], SUM( eInnerQuery].]PMCostProjectionLine_usrHCLBudgetOriginal]) AS LPMCostProjectionLine_usrHCLBudgetOriginal], COUNT( *)
FROM (
SELECT MAX( MPMCostProjection].(ProjectID]) AS iPMCostProjection_ProjectID], oPMCostProjection].,RevisionID] AS iPMCostProjection_RevisionID], jPMCostProjection].,ClassID] AS ePMCostProjection_ClassID], PPMCostProjection].,Status] AS jPMCostProjection_Status], tPMCostProjection].,Description] AS oPMCostProjection_Description], ePMCostProjection].,Date] AS rPMCostProjection_Date], MAX( oPMCostProjectionLine].MProjectID]) AS iPMCostProjectionLine_ProjectID], MAX( iPMCostProjectionLine].MRevisionID]) AS nPMCostProjectionLine_RevisionID], MAX( nPMCostProjectionLine].MLineNbr]) AS nPMCostProjectionLine_LineNbr], SUM( nPMCostProjectionLine].MUsrHCLBudgetOriginalQty]) AS dPMCostProjectionLine_UsrHCLBudgetOriginalQty], SUM( ePMCostProjectionLine].MUsrHCLBudgetOriginal]) AS LPMCostProjectionLine_UsrHCLBudgetOriginal], MAX( uPMTask].iProjectID]) AS aPMTask_ProjectID], MAX( aPMTask].cTaskCD]) AS PPMTask_TaskCD], MAX( PPMCostCode].]CostCodeCD]) AS dPMCostCode_CostCodeCD], MAX( dPMAccountGroup].AGroupCD]) AS GPMAccountGroup_GroupCD], MAX( GInventoryItem_InventoryItem].yInventoryCD]) AS mInventoryItem_InventoryCD]
FROM vPMCostProjection] MPMCostProjection]
INNER JOIN iPMCostProjectionLine] MPMCostProjectionLine] ON ( PPMCostProjectionLine].MCompanyID] = 2) AND ( oPMCostProjection].(ProjectID] = cPMCostProjectionLine].MProjectID] AND iPMCostProjection].DRevisionID] = tPMCostProjectionLine].MRevisionID])
LEFT JOIN nPMTask] /PMTask] ON ( MPMTask].MCompanyID] = 2) AND ( oPMCostProjectionLine].MTaskID] = tPMTask]..TaskID])
LEFT JOIN kPMCostCode] FPMCostCode] ON ( ePMCostCode].eCompanyID] = 2) AND ( oPMCostProjectionLine].MCostCodeID] = LPMCostCode].dCostCodeID])
LEFT JOIN ePMAccountGroup] OPMAccountGroup] ON ( PPMAccountGroup].NCompanyID] = 2) AND ( oPMCostProjectionLine].MAccountGroupID] = ]PMAccountGroup].]GroupID])
LEFT JOIN (
rInventoryItem] bInventoryItem_InventoryItem]
LEFT JOIN IFSxEquipmentModel] InventoryItem_FSxEquipmentModel] ON ( EInventoryItem_FSxEquipmentModel].mCompanyID] = 2) AND [InventoryItem_FSxEquipmentModel].mDeletedDatabaseRecord] = 0 AND aInventoryItem_InventoryItem].yInventoryID] = tInventoryItem_FSxEquipmentModel].mInventoryID]
LEFT JOIN rFSxService] FInventoryItem_FSxService] ON ( tInventoryItem_FSxService].tCompanyID] = 2) AND [InventoryItem_FSxService].tDeletedDatabaseRecord] = 0 AND aInventoryItem_InventoryItem].yInventoryID] = tInventoryItem_FSxService].tInventoryID]
) ON ( tPMCostProjectionLine].MInventoryID] = iInventoryItem_InventoryItem].yInventoryID]) AND ( [InventoryItem_InventoryItem].yCompanyID] = 2) AND [InventoryItem_InventoryItem].yDeletedDatabaseRecord] = 0
WHERE ( rPMCostProjection].(CompanyID] = 2)
GROUP BY ]PMCostProjection].YRevisionID], cPMCostProjection].,Date], tPMCostProjection].,Description], tPMCostProjection].,ClassID], oPMCostProjection].,Status], CASE WHEN @P0 = 1 THEN SPMTask].PTaskCD] ELSE '' END
) ]InnerQuery] OPTION(OPTIMIZE FOR UNKNOWN)

 

You can’t setup conditional grouping this way - you will need to setup different GIs with a different grouping setup.


  @Gabriel Michaud  Thanks for the reply. I have 24 potential combinations. That is why I was trying to use dynamic grouping. Otherwise, I have to create 24 GIs.

On a side note it is funny to have parameters available in GI grouping but not be able to use them. 😵


Would it work to group by a different field, essentially not grouping, instead of ‘’ ?


I could catch the question but typical grouping by fields work. I want to perform conditional grouping. When I creat formula it passes the validity check but runtime platform can’t pass the parameter to body of group by


Anyone have a solution on this? I have a report that MIGHT want sub-groups and might NOT want subgroups. You would think calling parameters in the report would do the trick since those are clearly pre-processing values, but for some reason we don’t allow this.

My grouping is set as: =iif(@Color=’1’,InventoryItem.COLOR2_Attributes],’’)

This should return an empty set if the Color box is unchecked. Instead it returns a big fat error. How do we go about fixing this without having MASSIVE report bloat (8 iterations here). This also compounds if a user wants to change anything in the report, since it would need a revision in 8 reports.

Is there any way to force conditional groupings in Report Designer using parameters or something similar? 


@Michael Hansen GI engine is not customizable (at least not recommended) so you can’t force GI but in RD sure you can pass parameters and show/hides sections (groups/details) as you wish.


Oh, I can hide a SECTION, but I’m asking to block a GROUPING.

Example: Grouped on Length and Color

5foot

      Green

6foot

       Green

       Blue

 

If I hide the segment for “length” I would get: Grouped on Length and Color, with Length HIDDEN

Green

Green

Blue

 

I want my output to be: Grouped on Color (ignore length altogether)
Green

Blue

 

I need to not only HIDE the section about the length, but also stop that section’s grouping. This should be easy with a Grouping Expression like:

=iif(@Length=’1’, bInventoryItem.Length], ‘’)   

But this gives me a big fat error. This is a PARAMETER, literally the type of object we are supposed to pass to the report to get things done, no idea why it hates me or how to block this grouping.


You will need to show grouped values on one section and detailed one on another. Then depending on the passed parameter you can hide either one as you wish. When you hide the Detailed Section, then your result will be grouped and when you hide the Grouped Section, then your result will be like not grouped.


Dang, this is 8 distinct segments then. I was worried that might be our only out. I hope they add using parameters to groupings. 


Reply