Navigation using LINK FIELD and WITH not working

I have a Document Link -->

I have a column layout with image field and document image and a dynamic link with a label and a value saved into action_txt local variable as below.

 a!columnLayout(
                a!imageField(
                  images: {
                    a!documentImage(
                      document: cons!POC_IMG,
                      link: a!dynamicLink(
                        label: "CLICK_HERE",
                        value: "CLICK_HERE",
                        saveInto: {
                          local!action_txt
                        }
                      )
                    ),
                        
                  },
                  size: local!imageSize
                )

I then call a WITH function which has an IF statement in it wherein if the value of the variable action_txt is CLICK_HERE, it should call another rule which is a report with a grid layout. But the below does not seem to work for some reason. The  ON CLICK does not invoke the report. Any idea why?

with(
      local!masterDatasubset:if(local!action_txt="CLICK_HERE",rule!POC_PrintReport(),{}),
 

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Can you post your full code?  If so, please use the insert -> code functionality to create a code box which will keep your reply to a reasonable size and retain formatting.

  • load(
      local!test,
      local!action_txt,
      local!action,
      local!imageSize: "FIT",
      local!masterDatasubset,
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20
        /*sort: a!sortInfo(*/
          /*field: "id",*/
          /*ascending: false*/
        /*)*/
      ),
      with(
          local!masterDatasubset:
          if(local!action_txt="CLICK_HERE",
          rule!POC_Report(),{}),
      a!formLayout(
        
            contents: {
              
                        
                  
                    a!imageField(
                      images: {
                        a!documentImage(
                          document: cons!POC_IMG,
                          link: a!submitLink(
                            label: "CLICK_HERE",
                            value: "CLICK_HERE",
                            saveInto: {
                              local!action_txt
                              
                            }
                          )
                        )
                             
                      },
                      size: local!imageSize
                    )
                  
                }
              )
            
            
          )
         
          
          )

    Here you are

    .

    Note --> POC_Report is a report created using Report Builder.

  • 0
    Certified Lead Developer
    in reply to aneeshv713

    So you're setting the value of your local variable, local!masterDataSubset, to whatever is returned by rule!POC_Report... but it looks like you're never actually using local!masterDataSubset in your interface.

    Also, i'm unclear why you have local!masterDataSubset defined in your load() and then again in your with()... if it doesn't give you an error outright, anything inside the with() will just reference the with() version of the variable and ignore the load() version, making the load() version useless.

  • So, what should be the correct way of coding this?

  • 0
    Certified Lead Developer
    in reply to aneeshv713

    It depends on what you're doing inside rule!POC_Report... if it's returning a dictionary of data or thereabouts, you need to add a component to display its data inside the contents: parameter of your a!formLayout (such as a grid); but if that rule is actually an interface itself, then you would need to move it out of the with() variable and into the formLayout's contents, wrapping it in the same "if" logic there.

  • It’s a report interface built using a report builder.  

  • 0
    Certified Lead Developer
    in reply to aneeshv713

    Then you probably need to try the second option I suggested.

    Edit: please try the structure I've prepared here - it's your original code as above but with some unnecessary stuff commented out (like the entire with() statement since it's unnecessary at the moment), and the report rule called appropriately inside the formLayout contents.

    Please also note that rule!POC_Report will need to only contain elements that are allowed to be nested within the contents of a!formLayout, such as a section, box layout, or individual component or array of components.  If, for example, the rule contains its own a!formLayout for some reason, i would expect you'll get an error when trying my code.

    load(
      local!test,
      local!action_txt,
      local!action,
      local!imageSize: "FIT",
      /*local!masterDatasubset,*/
      local!pagingInfo: a!pagingInfo(
        startIndex: 1,
        batchSize: 20
      ),
      
      /*with(*/
        /*local!masterDatasubset: if(*/
          /*local!action_txt="CLICK_HERE",*/
          /*rule!POC_Report(),*/
          /*{}*/
        /*),*/
      
        a!formLayout(
          contents: {
            a!imageField(
              images: {
                a!documentImage(
                  document: cons!POC_IMG,
                  link: a!submitLink(
                    label: "CLICK_HERE",
                    value: "CLICK_HERE",
                    saveInto: {
                      local!action_txt
                    }
                  )
                )
              },
              size: local!imageSize
            ),
            
            if(
              local!action_txt="CLICK_HERE",
              rule!POC_Report(),
              {}
            )
            
          }
        )
      /*)*/
    )