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
Views
Replies
Total Likes
Maybe this can help you, you have a lot of Javascript properties
https://experienceleague.adobe.com/developer/campaign-api/api/index.html
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.
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.
Thanks,
Parvesh
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.
Views
Replies
Total Likes
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:
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:
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.
@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.
Views
Replies
Total Likes
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!
Views
Replies
Total Likes
Views
Likes
Replies