Skip to main content
williamm0010
July 27, 2022
Solved

How Do I Remove A Blank Record From a CDT in the process model?

  • July 27, 2022
  • 3 replies
  • 0 views

Hello,

In my process model I have a CDT that I use to pass in to a form.  In the process model is there a way to remove a blank record.

In my CDT the very first record is always empty, so when I pass the CDT to the form my editable grid on the first row is empty with no data.

I am trying to figure out how I can delete the first record from the CDT before passing it to the form in the process model.

The CDT is multi and can hold more than 1 record as well.

Thank you for any help

Best answer by csteward

If you are always removing the first row in the CDT, in a Script Task you can use the remove() function over the CDT in an output expression, save it back to the same CDT and you will be left with all rows other than the first:

a!localVariables(
  local!cdt: {
    'type!{urn:com:gdit:types}COE_Sample_CDT'(),
    'type!{urn:com:gdit:types}COE_Sample_CDT'(id: 1)
  },
  
  remove(local!cdt,1)
)

If you can have null values throughout the CDT, you can clear them with an expression such as:

a!localVariables(
  local!cdt: {
    'type!{urn:com:gdit:types}COE_Sample_CDT'(),
    'type!{urn:com:gdit:types}COE_Sample_CDT'(id: 1),
    'type!{urn:com:gdit:types}COE_Sample_CDT'()
  },
  
  a!flatten(
    fn!reject(
      fn!isnull,
      a!forEach(
        items: local!cdt,
        expression: if(
          rule!APN_isBlank(fv!item.id),
          null,
          fv!item
        )
      )
    )
  )
)

3 replies

csteward
cstewardAnswer
July 27, 2022

If you are always removing the first row in the CDT, in a Script Task you can use the remove() function over the CDT in an output expression, save it back to the same CDT and you will be left with all rows other than the first:

a!localVariables(
  local!cdt: {
    'type!{urn:com:gdit:types}COE_Sample_CDT'(),
    'type!{urn:com:gdit:types}COE_Sample_CDT'(id: 1)
  },
  
  remove(local!cdt,1)
)

If you can have null values throughout the CDT, you can clear them with an expression such as:

a!localVariables(
  local!cdt: {
    'type!{urn:com:gdit:types}COE_Sample_CDT'(),
    'type!{urn:com:gdit:types}COE_Sample_CDT'(id: 1),
    'type!{urn:com:gdit:types}COE_Sample_CDT'()
  },
  
  a!flatten(
    fn!reject(
      fn!isnull,
      a!forEach(
        items: local!cdt,
        expression: if(
          rule!APN_isBlank(fv!item.id),
          null,
          fv!item
        )
      )
    )
  )
)

williamm0010
July 27, 2022

Thank you, Thank you, Thank you.  The solution you provided worked.

July 28, 2022

In a Script Task, you may apply the remove() method over the CDT in an outp if you always delete the first row in the CDT.

basketball stars