Changing CDT Field Names

Hello,

We have a CDT in our application to match an Excel file that is being uploaded. If the Excel template changes (ie. column headers are renamed and rearranged), what is the best practice for getting the CDT to match the new Excel file being imported?

If I edit the XSD of the CDT to match the new Excel template, will all dependencies automatically update under the CDT?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Associate Developer

    Hello  ,

    Since your excel template as mentioned will not have fixed column names, you will have to manually update your CDT and the best practice to do so is by updating the XSD file. 

    Coming to dependencies, you will have to manually update where you are using the map logic from your data to CDT (as it is not mentioned above in the question of how you are importing the data from excel, I'm assuming that you are using read excel function in the expression which needs to be updated when the CDT is being updated).

  • Hi Rithani, so in this case it will be a one time change to the Excel template and will have fixed column names moving forward. For example, let's say the new version of the Excel template will have column headers 'Last Name, First Name, Address' instead of 'FN, LN, Address'. Notice each Excel file has the same three data points, but the order and name has changed in the file being uploaded to Appian. Since the current CDT matches the naming conventions of 'FN, LN, Address', I am wondering the best method to update the app to address this?

  • This is one of many reasons why I will never go back to using smart services to import Excel files again, since I've started using fn!readexcelsheetpaging(), also from the Excel Tools plugin.

    You have full control over casting data to your CDT, including type conversions, validations, etc.

    This eliminates the need of having a specific CDT that matches the Excel file, we simply bypass the header row and only use column index.

    This does not break if there is an issue in the file such as an empty row (I forget the cases).

    In this situation, if you switch to fn!readexcelsheetpaging() in an expression rule / script task for import, you don't have to modify your CDT.

    a!localVariables(
      local!doc: cons!APP_UPLOAD_DOC,
      local!data: fn!readexcelsheetpaging(local!doc,0,a!pagingInfo(1,cons!APP_UPLOAD_MAX_ROWS)
      ),
    
      if(
        local!data.totalCount=0,
        {},
        reject(
          rule!APN_isEmpty,
          a!flatten(
            a!forEach(
              items: remove(local!data.data,1),
              expression: {
                'type!{urn:com:appian:types}YOUR_CDT_HERE'(
                  id: null,
                  part: index(fv!item.values,1,""),
                  model: index(fv!item.values,2,""),
                  desc: index(fv!item.values,3,"")
                )
              }
            )
          )
        )
      )
    )

Reply
  • This is one of many reasons why I will never go back to using smart services to import Excel files again, since I've started using fn!readexcelsheetpaging(), also from the Excel Tools plugin.

    You have full control over casting data to your CDT, including type conversions, validations, etc.

    This eliminates the need of having a specific CDT that matches the Excel file, we simply bypass the header row and only use column index.

    This does not break if there is an issue in the file such as an empty row (I forget the cases).

    In this situation, if you switch to fn!readexcelsheetpaging() in an expression rule / script task for import, you don't have to modify your CDT.

    a!localVariables(
      local!doc: cons!APP_UPLOAD_DOC,
      local!data: fn!readexcelsheetpaging(local!doc,0,a!pagingInfo(1,cons!APP_UPLOAD_MAX_ROWS)
      ),
    
      if(
        local!data.totalCount=0,
        {},
        reject(
          rule!APN_isEmpty,
          a!flatten(
            a!forEach(
              items: remove(local!data.data,1),
              expression: {
                'type!{urn:com:appian:types}YOUR_CDT_HERE'(
                  id: null,
                  part: index(fv!item.values,1,""),
                  model: index(fv!item.values,2,""),
                  desc: index(fv!item.values,3,"")
                )
              }
            )
          )
        )
      )
    )

Children
No Data