web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

JScript to capture/store variables when custom button is clicked

(0) ShareShare
ReportReport
Posted on by

HI all, 
I have to do something I have not done before, which is on click of an "Activate Account" button, to store certain values on the Account as variables via JavaScript, which are shown below.

  1.   "lastName": "string",
  2.   "firstName": "string",
  3.   "businessphone": "string", 
  4.   "email": "string",  
  5.   "address1": "string",
  6.   "address2": "string",
  7.   "city": "string",
  8.   "state": "string",
  9.   "zipCode": "string",
  10.   "businessName": "string",
  11.   "deepLink": "string",
  12.   "urlPrefix": "string"

    Once the Button is clicked, it needs to be then hidden, and a custom field bf_accountactivatedflag needs to be set to true.

    The "Activate Account" custom button from Ribbon Workbench only shows when Customer Type (bf_customertype_ = 'B2B' (979580001)

    See screenshots below of the UI:

    pastedimage1662580165234v1.png

    pastedimage1662580192900v2.png

    Can anyone share sample code that would achieve the storing of the variables shown above?  I just need some help getting started...

    Thanks in advance!


I have the same question (0)
  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Chrisbra22,

    First, you need to customize the command for this out-of-the-box Activate button. To hide it, you need to add the 'enable rule' with the logic:

    if (bf_accountactivatedflag === true OR bf_customertype_ = 'B2B' (979580001))
        return false;
    else
     return true;

    When the activate button triggers you need to set  bf_accountactivatedflag to true. For that purpose write

    1. workflow on change of status.
      1. add condition when status = active
      2. Update bf_accountactivatedflag  to true
    2. plugin on change of status in pre-update
      1. add condition when status = active
      2. Update bf_accountactivatedflag  to true
    3. similarly, power automate
    4. or even you can use calculate column

    on click of an "Activate Account" button, to store certain values on the Account as variables via JavaScript, which are shown below. For this purpose, you need to customize the out-of-the-box command.

     

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp: 923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Chrisbra22 Profile Picture
    on at

    Hi, thanks for the quick response! 

    I have the button created and show/hide logic in place via Ribbon Workbench.  

    All I really need is the code to store the string values for the fields listed when event "button is clicked by user' is achieved.  Is that something you can assist with - i.e., sample code to store values when a button is clicked?  We need to store these values, and then send them via API to another source later.  

    I can worry about the flags later.  Is the Javascript to store variables something you are familiar with?  

    Thanks again!  

  • Suggested answer
    Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Chrisbra22,

    Why you are intended to use or store these variables using JS> I already told you for this purpose you need to customize the command of Activate button. 

    As per my experience, there are many better ways to fulfil your requirement. You can do it with the below:

    1. Workflow
    2. Power automate
    3. Plugin

    Using these you will achieve the same functionality that you are intending to do with JS.

    You can also do it with JS but it is a complicated way to achieve. Customize the existing Activate button command and all...

    You can call your APIS through

    1. plugins
    2. workflow extensions
    3. power automates

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans