UI action condition with script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 06:58 AM
Hello.
I have a UI action where the condition is a script include, and its not working.
Here is how i did the ui action condition:
and here is the script include:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2024 10:15 AM
Hi @asd22
Your script include contains only initialize function and no other methods, it won't be very useful for conditions in a UI Action. You need to add a method to your Script Include that contains the logic for your condition and returns a boolean value.
Here's how you can modify your Script Include to include a method for your condition:
var conditions_hidestudbutton = Class.create();
conditions_hidestudbutton.prototype = {
initialize: function() {
// Initialization code, if necessary
},
shouldDisplayButton: function() {
// Your conditions logic here
// Return true to display the button, false to hide it
return true; // or false based on your conditions
},
type: 'conditions_hidestudbutton'
};
In the example above, I've added a shouldDisplayButton method that contains the logic for determining whether the UI Action should be displayed.
Once you have your Script Include set up with the new method, you can call it in the condition field of your UI Action like this:
new conditions_hidestudbutton().shouldDisplayButton();
This line will instantiate your conditions_hidestudbutton class and call the shouldDisplayButton method. The UI Action will then use the boolean value returned by this method to determine whether to display the UI Action.
Remember to make sure that your Script Include is marked as Client Callable if you are using it in a client-side context. If your condition logic needs to run on the server side, you should not use a Script Include in the condition field of a UI Action; instead, you would handle the logic within the server-side script portion of the UI Action.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-02-2024 03:00 AM
Hello sorry for the late respond, i tried this but i have some issues with the button not showing up at all now