Skip to main content
madhup0005
March 7, 2025
Question

Validation on Grid Plus

  • March 7, 2025
  • 3 replies
  • 0 views

Hi All,

I am using gridPlusLayout , i want to know how can we put validation on columnConfigs.

1.Like if want to put validation for null or empty.

2. the second concern is when i am editing a field after made changes it save data into separate variable, but every time when we load grid it by default creates a null empty row and add that row also in save data variable. so when i am saving that record  in record type it thorw error because a null type or row is also adding into save data variable. 

It works fine when we manually remove that data from grid but when we don't remove that causes error. So how to handle this situation.

    3 replies

    stefanhelzle0001
    March 7, 2025

    Can you share some example code?

    madhup0005
    March 7, 2025

    a!localVariables(
      local!changeData: {},
      local!deletedData:{},
      local!structureType:  {"rooftop", "micro"},
      local!region: {"bc"},
      local!coverageType:  {"macro","micro"},
      local!uniqueStructuretype: union(
        local!structureType,
        local!structureType
      ),
      local!uniqueRegion: union(local!region, local!region),
      local!uniqueCoverageType: union(local!coverageType, local!coverageType),
      local!isDisable: false,
      local!gridData: rule!MTFT_getTftData(),
      local!record: a!forEach(
        items: local!changeData,
        expression: cast(
          'recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules',
          fv!item
        )
      ),
       
      local!deafultGridData:local!gridData,
      
        
    
      a!formLayout(
        contents: {
          a!sectionLayout(
            label: "Manage Forecast Date Rules",
            labelIcon: "user-edit",
            contents: {
              a!columnsLayout(
              
                columns: {
                  a!columnLayout(
                    
                    contents: a!boxLayout(
                    label: "Instructions",
                    contents: {
                      a!cardLayout(
                        contents: {
                          a!sideBySideLayout(
                            items: {
                              a!sideBySideItem(
                                item: a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextIcon(
                                      icon: "info-circle",
                                      color: "#555",
                                      size: "MEDIUM"
                                    )
                                  }
                                ),
                                width: "MINIMIZE"
                              ),
                              a!sideBySideItem(
                                /* Replace this rich text with your information message */
                                item: a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    cons!MTFT_FORECAST_DATE_RULES_INSTRUCTIONS[1]
                                  }
                                )
                              )
                            },
                            alignVertical: "MIDDLE"
                          )
                        },
                        style: "STANDARD",
                        marginBelow: "STANDARD",
                        accessibilityText: "Information message"
                      ),
                      a!cardLayout(
                        contents: {
                          a!sideBySideLayout(
                            items: {
                              a!sideBySideItem(
                                item: a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    a!richTextIcon(
                                      icon: "info-circle",
                                      color: "#555",
                                      size: "MEDIUM"
                                    )
                                  }
                                ),
                                width: "MINIMIZE"
                              ),
                              a!sideBySideItem(
                                /* Replace this rich text with your information message */
                                item: a!richTextDisplayField(
                                  labelPosition: "COLLAPSED",
                                  value: {
                                    cons!MTFT_FORECAST_DATE_RULES_INSTRUCTIONS[2]
                                  }
                                )
                              )
                            },
                            alignVertical: "MIDDLE"
                          )
                        },
                        style: "STANDARD",
                        marginBelow: "STANDARD",
                        accessibilityText: "Information message"
                      )
                    },
                    style: "#FFFFFF",
                    shape: "ROUNDED",
                    isCollapsible: true,
                    isInitiallyCollapsed: true,
                    marginBelow: "STANDARD"
                  )
                  ),
                  a!columnLayout(contents:   a!buttonLayout(
                    primaryButtons: a!buttonWidget(
                      label: "Save",
                      value: true,
                      saveInto: {
    
                        a!save(ri!tftRules['recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{4372a136-1961-4168-842f-60543664d9b9}createdBy'], loggedInUser()),
                        a!save(ri!tftRules['recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{87abe090-0ef4-4efd-8d62-59b8f07e98de}createdDate'], now()),
                        a!save(ri!tftRules['recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{c4ea5ff1-bb01-48a3-a9af-9003cd1e0efc}isDeleted'], false),
                        
    
                        a!startProcess(
                          processModel: cons!MTFT_MANAGE_FORECAST_DATE_RULES_PM,
                          processParameters: { TFTRules: ri!tftRules, cancel: ri!cancel },
    
                        ),
    
                      },
                      submit: true,
                      style: "SOLID",
                      disabled: if(local!isDisable, false, true),
                      validate: false()
    
                    ),
    
    
                  ))
                  
                }
              ),
             
             
              
            }
          ),
          gridPlusLayout(
            label: " ",
            labelPosition: "ABOVE",
            validations: {},
            height: "AUTO",
            rowsValue: rule!MTFT_getTftData(),
            rowsSaveInto: {
              ri!tftRules
            
            },
            primaryKeyFieldName: tostring('recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{32565a2f-3b42-4ea7-b017-1f042bff8df1}idRule'),
            columnConfigs: {
              textcolconfig(
                field: "idRule",
                title: "Rule",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: true,
                colWidth: 10
              ),
              dropdowncolconfig(
                field: tostring('recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{3d15dc17-a294-4c02-aee1-087a2fca5a14}structureType'),
                source: local!uniqueStructuretype,
                strict: true,
                filter: true,
                title: "Structure Type",
                relationshipName: null,
                validator: null,
                /*validator(*/
                  /*name: "Structure type should not be empty ",*/
    /*             */
                  /*operator:"isNotNullOrEmpty",*/
                  /*value: null*/
                /*),*/
                readOnly: false,
                colWidth: 250
              ),
              dropdowncolconfig(
                field: "coverageType",
                source: local!uniqueCoverageType,
                strict: true,
                filter: true,
                title: "Coverage Type",
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 250
              ),
              dropdowncolconfig(
                field: "region",
                source: local!uniqueRegion,
                strict: true,
                filter: true,
                title: "Region",
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 250
              ),
              textcolconfig(
                field: "pmGoConstruction",
                title: "PMGo Construction",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: "materialRequired",
                title: "Material Required",
                linkConfig: Null,
                relationshipName: null,
                validator:  null,
    
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: tostring('recordType!{a335f9cf-6867-4270-aed4-53c7bdcc9404}MTFT Default Rules.fields.{cdf0e62d-2b2a-44a4-a973-fb165bdc031a}constructionStart'),
                title: "Construction  Start",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: "constructionEnd",
                title: "Construction End",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: "atpReady",
                title: "ATP Ready",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: "atpComplete",
                title: "ATP Complete",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              ),
              textcolconfig(
                field: "forecastedOnAir",
                title: "Site OnAir",
                linkConfig: Null,
                relationshipName: null,
                validator: null,
                readOnly: false,
                colWidth: 300
              )
            },
            changeDataValue: local!changeData,
            changeDataSaveInto: {
              local!changeData,
              a!save(local!isDisable, true)
              
            },
            deleteDataValue: local!deletedData ,
            deleteDataSaveInto: local!deletedData,
            readOnly: null,
            rowHeaders: true,
            hiddenFields: null,
            showPrimaryKey: false
          )
        },
        
      )
      
    )