Expand my Community achievements bar.

Delete List field

Avatar

Level 3

Hi,

 

I want to delete one of the field of list using JS activity or SQL Code activity through workflow, is it possible? If so, how to do it.

 

Thanks

6 Replies

Avatar

Community Advisor

Hello @parmeshwarr3905 ,

 

To delete a field from existing listing, first you need find the SQL table name behind that list and then you can delete it. 

Then you need to delete that filed form SQL table. I believe it would not be good option. you might get some error after that. 

 

There are some other easy way also to do this, but it depend upon your requirement. I mean do you want to do only one time or recurring, is data is important in this list etc.

If it is one time task: 

1. Load this list in workflow. 

 2. Add a query activity, select  the temp schema option and select the schema.

Parvesh_Parmar_0-1681478615314.png

3. Add the fields you need in additional data. Do not include which you need to delete. 

4. Create a new list. 

5. You can delete the original list.

6. Rename the new list with original internal name and label. 

Parvesh_Parmar_1-1681478743474.png

 

Thanks, 

Parvesh

 

 

Avatar

Level 3

Hi @Parvesh_Parmar it's a recurring process. once I store the data in list(from file or other sources) if a particular column is empty then in that case I want to delete the field.

e.g.

I have 3 files

file1: column A, column B, column C

file2: column A, column B, column C

file3: column A, column B, column C

 

in file2 if column C is empty I just want to remove it from list.

 

Avatar

Employee Advisor

@parmeshwarr3905 ,

It is possible to delete a field from a list using either a JS activity or a SQL code activity in a workflow.

Here are the steps to do it using a JS activity:

  1. Create a new JS activity in your workflow.
  2. In the JS code, use the xtk namespace to access the schema of the list and the field you want to delete. For example:

var schema = xtk.schema.load("myList");

schema.fields.remove("fieldName");

Replace myList with the name of your list and fieldName with the name of the field you want to delete.

Save the JS activity and run the workflow to delete the field. To do it using a SQL code activity:

  1. Create a new SQL code activity in your workflow.
  2. In the SQL code, use a SQL ALTER TABLE statement to drop the column you want to delete. For example:

ALTER TABLE myList DROP COLUMN fieldName;

Replace myList with the name of your list and fieldName with the name of the field you want to delete.

Save the SQL code activity and run the workflow to delete the field.

Note that deleting a field from a list can have potential consequences on other workflows or programs that use this field. It is recommended to test this change in a non-production environment and consider the impacts on other workflows or programs before making the change in a production environment.

Avatar

Level 3

@akshaaga I tried both JS & SQL approach, getting error.

 

Error with SQL: 

PGS-220000 PostgreSQL error: ERROR: relation "LISTNAME" does not exist .

 

Error with JS:

XTK-170031 Key value 'LISTNAME' is incompatible on element 'schema' for schema 'Entities schemas (xtk:schema)'

 

please let me know what went wrong.

Avatar

Administrator

Hi @parmeshwarr3905,

Were you able to resolve this query with the help of the given solutions or do you still need more help here? Do let us know. In case the given solutions were helpful, then kindly choose the one that helped you the most as the 'Correct Reply'.
Thanks!



Sukrity Wadhwa