DEV Community

Thom
Thom

Posted on • Edited on

3 2

"Assign to me" declarative action in workspace

Let's be fancy and not use the old ui action for our assigned to me button, lets use the new declarative actions.

To do that you first need to create an action bar declarative action same as in my previous post (https://dev.to/23thom/add-a-new-button-to-your-action-bar-on-a-workspace-4445).
Use the implement as 'UXF Client Action' and create a new Action Payload Definition. Tell the payload definition that it is applicable to 'form'. As we will make everything dynamic, we don't need to add a payload (we can if we want to).

Do the same as in the previous post with the UX Form Action Layout so the button shows up in the action bar on your workspace.

Lets go back to our workspace and lets create on our page level a handled event. That is our container were we put in other events. I called mine ThomsEvent :)

Image description

Now we need to got to 'sys_ux_addon_event_mapping', our UX Add-on Event Mapping table, to connect our declarative action to our handled event. So when we click on the button, our handled event gets fired and we can do a good old setValue from our gform data broker.

Image description
Please be aware, that the handled event just shows up on the record page that is used in our workspace.

Now we will see our handled event on the page level event mappings.

Image description

Here we can now add a SET_VALUE event from our gform data broker.

We can then use the script mode to create our dynamic payload and use the context.session object to get dynamically the user sys_id.

function evaluateEvent({api, event}) {
    return {
        fieldName: 'assigned_to',
        value: api.context.session.user.sys_id,
        displayValue: api.context.session.user.fullName
    };
}

Enter fullscreen mode Exit fullscreen mode

Thats it! :) We could now also add a save event from our gfrom data broker, if we want to.
Have fun!

AWS Security LIVE!

Tune in for AWS Security LIVE!

Join AWS Security LIVE! for expert insights and actionable tips to protect your organization and keep security teams prepared.

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Immerse yourself in a wealth of knowledge with this piece, supported by the inclusive DEV Community—every developer, no matter where they are in their journey, is invited to contribute to our collective wisdom.

A simple “thank you” goes a long way—express your gratitude below in the comments!

Gathering insights enriches our journey on DEV and fortifies our community ties. Did you find this article valuable? Taking a moment to thank the author can have a significant impact.

Okay