We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Replicate UI Action Button Behaviour in Project Workspace

andrewbettc
Kilo Sage

Hi,

There is a button that appears in the Risks related list on the Project Form called "Create from Library". When you click it you can add a risk to the project from the risk library. A modal pops up like this:

AndrewBettcher_0-1768486483293.png


I've added a new "Related List Declarative Action" (on sys_declarative_action_assignment) and, to test, I just set it to give me a console log. 


 The button appears in the right place on the project workspace like this:

AndrewBettcher_1-1768486579457.png

But when I click it, I get an error saying Failed to execute action. Please contact your administrator.
This is my declarative action:

AndrewBettcher_2-1768486648924.png



Note that I am not able to select the project workspace in the workspace field. The only option there is "Agent Workspace".

What am I doing wrong?

 

 






1 ACCEPTED SOLUTION

Diogo Ramos
Giga Sage

Hello, I have just created the same example for other table to test and I have no problems as long I have the function onClick() 

DiogoRamos_1-1768550104195.png

I did with alert, but it also worked with console.log :

DiogoRamos_2-1768550338633.png

 

this is the code :

function onClick() {
 
alert("this is a test");
console.log("test");
}


If I remove the function onClick() with the same code I do get the error you are mentioning : 

DiogoRamos_3-1768550539771.png


Can you check if you have the function and give it a try ? 

I hope this helps

 

 

View solution in original post

3 REPLIES 3

Diogo Ramos
Giga Sage

Hello, I have just created the same example for other table to test and I have no problems as long I have the function onClick() 

DiogoRamos_1-1768550104195.png

I did with alert, but it also worked with console.log :

DiogoRamos_2-1768550338633.png

 

this is the code :

function onClick() {
 
alert("this is a test");
console.log("test");
}


If I remove the function onClick() with the same code I do get the error you are mentioning : 

DiogoRamos_3-1768550539771.png


Can you check if you have the function and give it a try ? 

I hope this helps

 

 

Thank you. I can now get the popup to appear. 

Unfortunately, since posting, it has become clear that I need to set it up as a UXF Client Action (which doesn't work!!).

Either way, you solved the problem I posted. Thank you again.

Ankur Bawiskar
Tera Patron

@andrewbettc 

I agree with what @Diogo Ramos mentioned.

I just checked few OOTB Related list actions and it has the onClick function, add that and it should work fine

AnkurBawiskar_0-1768551278685.png

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader