Migration

Is it possible to migrate for instance a CDT but change the values to hide the real values?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • To randomize strings as such (and also apply the same to numeric values), create 2 helper rules:

    rule!chris_test_randomize_numeric(numeric)

    tointeger(
      joinarray(
        a!forEach(
          items: 1+enumerate(len(ri!numeric)),
          expression: {
            a!localVariables(
              local!random: tointeger(rand()*9-1)+1,
              if(
                and(
                  fv!isFirst,
                  local!random=0
                ),
                1, /* change to 1 to maintain length */
                local!random
              )
            )
          }
        )
      )
    )

    rule!chris_test_randomize_string(text)

    a!localVariables(
      local!alpha: "abcdefghijklmnopqrstuvwxyz",
      joinarray(
        a!forEach(
          items: code(ri!text),
          expression: {
            a!localVariables(
              local!random: index(local!alpha,tointeger(rand()*len(local!alpha)-1)+1,null),
              if(
                fv!item<97,
                upper(local!random),
                local!random
              )
            )
          }
        )
      )
    )

    Then call your new rules when converting your CDT:

    a!localVariables(
      local!data: {
        a!map(id: 1, firstName: "John", lastName: "Doe", salary: 50000),
        a!map(id: 2, firstName: "Jane", lastName: "Doe", salary: 55000),
        a!map(id: 3, firstName: "Timothy", lastName: "McDonald", salary: 45000)
      },
    
      a!forEach(
        items: local!data,
        expression: a!map(
          id: fv!item.id,
          firstName: rule!chris_test_randomize_string(text: fv!item.firstName),
          lastName: rule!chris_test_randomize_string(text: fv!item.lastName),
          salary: rule!chris_test_randomize_numeric(numeric: fv!item.salary)
        )
      )
    )