Hi Appian

i want to ask about editable grid that i have some problem with it

1- the first one is when upload the first document when upload another document it will duplicate the document again 

2- how can bring the document id for the document that i uploaded , please answer quicly 

  Discussion posts and replies are publicly visible

Parents
  • {
                  a!localVariables(
                    /*  
      * local!employees is provided in this recipe as a way to start with hard-coded
      * data. However, this data is identical to the data created from the entity-backed
      * tutorial. Replace the hard-coded data with a query to the employee data store
      * entity and all of the employee records from the tutorial will appear.
      *
      * To replace this data with your own, replace (ctrl+H or cmd+H) all references to
      * local!employees with your data source, either via rule input or local variable.
      */
    
                    local!originalString: tostring(loggedInUser()), 
                    local!dotCharacter: ".",
                    local!spaceCharacter: " ",
                    /* sojood barham@experts ps */
                    local!addedBy2: substitute(local!originalString, local!dotCharacter, local!spaceCharacter),
                    local!dotCharacter2: " barham@experts ps",
                    local!spaceCharacter2: "",
                    local!addedBy: substitute(local!addedBy2, local!dotCharacter2, local!spaceCharacter2),
    
    
                    local!employees,
                    local!document,
                    local!classification,
                    a!formLayout(
                     
                      contents: {
                        a!gridLayout(
                          totalCount: count(local!employees),
                          headerCells: {
                            a!gridLayoutHeaderCell(label: "Upload Document" ),
                            a!gridLayoutHeaderCell(label: "Name" ),
                            a!gridLayoutHeaderCell(label: "Clasification" ),
                            a!gridLayoutHeaderCell(label: "Updated By" ),
                            a!gridLayoutHeaderCell(label: "Updated On" ),
    
                            /* For the "Remove" column */
                            a!gridLayoutHeaderCell(label: "" )
                          },
                          /* Only needed when some columns need to be narrow */
                          columnConfigs: {
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    
                            a!gridLayoutColumnConfig(width: "ICON")
                          },
                          /*
            * a!forEach() will take local!employee data and used that data to loop through an
            * expression that creates each row.
            *
            * When modifying the recipe to work with your data, you only need to change:
            * 1.) the number of fields in each row
            * 2.) the types of fields for each column (i.e. a!textField() for text data elements)
            * 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
            */
                          rows: a!forEach(
                            items: local!employees,
                            expression: a!gridRowLayout(
                              id: fv!index,
                              contents: {
                                /* For the First Name Column*/
                                a!fileUploadField(
                                  label: "File Upload",
                                  labelPosition: "ABOVE",
                                  target: cons!RDA_DOCUMENT_CONSTANCT,
                                  maxSelections: 1,
                                  value: local!document,
                                  saveInto: {local!document},
                                  validations: {}
                                ),
                                /* For the Last Name Column*/
                                a!textField(
                                  label: "last name " & fv!index,
                                  value:{index(local!document,1,"null")},
                                  saveInto: fv!item.lastName,
                                  required:true
                                ),
                                /* For the Department Column*/
                                a!dropdownField(
                                  label: "department " & fv!index,
                                  placeholder: "-- Select -- ",
                                  choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
                                  choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
                                  value: local!classification,
                                  saveInto: local!classification,
                                  required:true
                                ),
                                /* For the Updated By Column*/
                                a!textField(
                                  label: "title " & fv!index,
                                  value: local!addedBy,
                                  saveInto: fv!item.title,
                                  required:true
                                ),
                                /* For the Updated on Column*/
                                a!textField(
                                  label: "phone number " & fv!index,
                                  placeholder:"555-456-7890",
                                  value: fv!item.phoneNumber,
                                  saveInto: fv!item.phoneNumber,
                                  validations: if( len(fv!item.phoneNumber) > 12, "Contains more than 12 characters. Please reenter phone number, and include only numbers and dashes", null )
                                ),
    
                                /* For the Removal Column*/
                                a!richTextDisplayField(               
                                  value: a!richTextIcon(
                                    icon: "close",
                                    altText: "delete " & fv!index,
                                    caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
                                    link: a!dynamicLink(
                                      value: fv!index,
                                      saveInto: {
                                        a!save(local!employees, remove(local!employees, save!value))
                                      }
                                    ),
                                    linkStyle: "STANDALONE",
                                    color: "NEGATIVE"
                                  )
                                )
                              }
                            )
                          ),
                          addRowlink: a!dynamicLink(
                            label: "Add Document",
                            /*
               * For your use case, set the value to a blank instance of your CDT using
               * the type constructor, e.g. type!Employee(). Only specify the field
               * if you want to give it a default value e.g. startDate: today()+1.
               */
                            value: {startDate: today() + 1},
                            saveInto: {
                              a!save(local!employees, append(local!employees, save!value))
                            }
                          ),
                          /* This validation prevents existing employee start date from changing to a date in the future*/
                          validations: if(
                            a!forEach(
                              items: local!employees,
                              expression: and( not( isnull( fv!item.id)), todate(fv!item.startDate) > today() )
                            ),
                            "Existing Employees cannot have an effective start date beyond today",
                            null
                          ),
                          rowHeader: 1
                        )
                      
                      }
                      /*buttons: a!buttonLayout(*/
                        /*primaryButtons: a!buttonWidget(*/
                          /*label: "Submit",*/
                          /*submit: true*/
                        /*)*/
                      /*)*/
                    )
                  )
    
                }

Reply
  • {
                  a!localVariables(
                    /*  
      * local!employees is provided in this recipe as a way to start with hard-coded
      * data. However, this data is identical to the data created from the entity-backed
      * tutorial. Replace the hard-coded data with a query to the employee data store
      * entity and all of the employee records from the tutorial will appear.
      *
      * To replace this data with your own, replace (ctrl+H or cmd+H) all references to
      * local!employees with your data source, either via rule input or local variable.
      */
    
                    local!originalString: tostring(loggedInUser()), 
                    local!dotCharacter: ".",
                    local!spaceCharacter: " ",
                    /* sojood barham@experts ps */
                    local!addedBy2: substitute(local!originalString, local!dotCharacter, local!spaceCharacter),
                    local!dotCharacter2: " barham@experts ps",
                    local!spaceCharacter2: "",
                    local!addedBy: substitute(local!addedBy2, local!dotCharacter2, local!spaceCharacter2),
    
    
                    local!employees,
                    local!document,
                    local!classification,
                    a!formLayout(
                     
                      contents: {
                        a!gridLayout(
                          totalCount: count(local!employees),
                          headerCells: {
                            a!gridLayoutHeaderCell(label: "Upload Document" ),
                            a!gridLayoutHeaderCell(label: "Name" ),
                            a!gridLayoutHeaderCell(label: "Clasification" ),
                            a!gridLayoutHeaderCell(label: "Updated By" ),
                            a!gridLayoutHeaderCell(label: "Updated On" ),
    
                            /* For the "Remove" column */
                            a!gridLayoutHeaderCell(label: "" )
                          },
                          /* Only needed when some columns need to be narrow */
                          columnConfigs: {
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
                            a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    
                            a!gridLayoutColumnConfig(width: "ICON")
                          },
                          /*
            * a!forEach() will take local!employee data and used that data to loop through an
            * expression that creates each row.
            *
            * When modifying the recipe to work with your data, you only need to change:
            * 1.) the number of fields in each row
            * 2.) the types of fields for each column (i.e. a!textField() for text data elements)
            * 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
            */
                          rows: a!forEach(
                            items: local!employees,
                            expression: a!gridRowLayout(
                              id: fv!index,
                              contents: {
                                /* For the First Name Column*/
                                a!fileUploadField(
                                  label: "File Upload",
                                  labelPosition: "ABOVE",
                                  target: cons!RDA_DOCUMENT_CONSTANCT,
                                  maxSelections: 1,
                                  value: local!document,
                                  saveInto: {local!document},
                                  validations: {}
                                ),
                                /* For the Last Name Column*/
                                a!textField(
                                  label: "last name " & fv!index,
                                  value:{index(local!document,1,"null")},
                                  saveInto: fv!item.lastName,
                                  required:true
                                ),
                                /* For the Department Column*/
                                a!dropdownField(
                                  label: "department " & fv!index,
                                  placeholder: "-- Select -- ",
                                  choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
                                  choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
                                  value: local!classification,
                                  saveInto: local!classification,
                                  required:true
                                ),
                                /* For the Updated By Column*/
                                a!textField(
                                  label: "title " & fv!index,
                                  value: local!addedBy,
                                  saveInto: fv!item.title,
                                  required:true
                                ),
                                /* For the Updated on Column*/
                                a!textField(
                                  label: "phone number " & fv!index,
                                  placeholder:"555-456-7890",
                                  value: fv!item.phoneNumber,
                                  saveInto: fv!item.phoneNumber,
                                  validations: if( len(fv!item.phoneNumber) > 12, "Contains more than 12 characters. Please reenter phone number, and include only numbers and dashes", null )
                                ),
    
                                /* For the Removal Column*/
                                a!richTextDisplayField(               
                                  value: a!richTextIcon(
                                    icon: "close",
                                    altText: "delete " & fv!index,
                                    caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
                                    link: a!dynamicLink(
                                      value: fv!index,
                                      saveInto: {
                                        a!save(local!employees, remove(local!employees, save!value))
                                      }
                                    ),
                                    linkStyle: "STANDALONE",
                                    color: "NEGATIVE"
                                  )
                                )
                              }
                            )
                          ),
                          addRowlink: a!dynamicLink(
                            label: "Add Document",
                            /*
               * For your use case, set the value to a blank instance of your CDT using
               * the type constructor, e.g. type!Employee(). Only specify the field
               * if you want to give it a default value e.g. startDate: today()+1.
               */
                            value: {startDate: today() + 1},
                            saveInto: {
                              a!save(local!employees, append(local!employees, save!value))
                            }
                          ),
                          /* This validation prevents existing employee start date from changing to a date in the future*/
                          validations: if(
                            a!forEach(
                              items: local!employees,
                              expression: and( not( isnull( fv!item.id)), todate(fv!item.startDate) > today() )
                            ),
                            "Existing Employees cannot have an effective start date beyond today",
                            null
                          ),
                          rowHeader: 1
                        )
                      
                      }
                      /*buttons: a!buttonLayout(*/
                        /*primaryButtons: a!buttonWidget(*/
                          /*label: "Submit",*/
                          /*submit: true*/
                        /*)*/
                      /*)*/
                    )
                  )
    
                }

Children