Catalog Item Variables Deletion

Alpcan
Tera Contributor

Hello eveyone, I have an issue about deletion of catalog item variables with script. My categories, catalog items and catalog item variables have been created and automated using script. But there is a problem about deletion of catalog item variables with script. I can't delete any catalog item variables. I have specified the script section I used below.

var gr = new GlideRecord("item_option_new");
	gr.addQuery('sys_scope',scope);
	gr.query();
	if(gr.next()){
		gr.deleteRecord(true);
        }

 

1 ACCEPTED SOLUTION

@Alpcan you might have to create a cross scope policy to do it via your scope 

navigate to Application -cross scope access and create a new one like below 

 

Screenshot 2023-08-09 at 17.50.29.png

 

Target scope is your scope and target name is your table name and select operation as delete 

and set status as allowed.

Screenshot 2023-08-09 at 17.51.04.png

Hope this helps 

Mark my answer correct if this helps you 

Thanks

View solution in original post

10 REPLIES 10

Mohith Devatte
Tera Sage
Tera Sage

Hello @Alpcan ,

You need to specify for which catalog item you are deleting the variables for by adding one more addQuery like below 

var gr = new GlideRecord("item_option_new");
	gr.addQuery('sys_scope',scope); // your scope name
gr.addQuery('cat_item','your_catalog_item_sys_id');

	gr.query();
	while(gr.next()){ // use while to delete multiple variables
		gr.deleteRecord(); //no need to pass true as param for deleteRecord method
        }

Hope this helps 

Mark my answer correct if this helps you 

Thanks

Hello @Mohith Devatte,

Thanks for your quick reply. I tried what you said, but I still could not delete it. When I check the logs, I can see the variable names of the catalog item.

var gr = new GlideRecord("item_option_new");
	gr.addQuery('sys_scope',scope);
	gr.addQuery('cat_item',cat_sys_id);
	gr.query();
	while(gr.next()){
		gs.info(gr.name);
		gr.deleteRecord();
	}

Alpcan_1-1691579702206.png

 

@Alpcan are you trying this in background scirpt ? 

 

please try running it in BG as it immediately shows in the output if it has scope issues to delete the record.

I am assuming its a cross scope issue where you don't have access to delete the records 

Please try running the script in BG and let me know the output 

Thanks

@Mohith Devatte there is the output. How can I solve this?

Alpcan_0-1691580812577.png