cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
newmay
Helper V
Helper V

Set field on save/update

Hi! 

 

I want to set a field attribute on save - its an boolean field. Yet with entity metadata it wont work. 

It is regarding the profile web form on the portal. 

 

Could you help me out to solve this with javascript? (To set the value after I submitted/updated the form via click on the button)

 

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @newmay 

 

Please use below code:

$("#bbg_approved").prop("checked", false);
$("#bbg_approved").closest("td").hide();

 

--------------------------
If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

View solution in original post

9 REPLIES 9
ragavanrajan
Super User
Super User

Hi @newmay 

 

Please have a look at the following article 

 

https://carldesouza.com/get-and-set-field-values-using-formcontext-and-javascript-with-dynamics-365/ 

 

Hope it helps.

------------

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

 

 

Hey @ragavanrajan  thanks! 

 

So basically I can copy the code from the article, yet how do I combine it with the click on the button, since it is on the portal.

 

I need the field value to be set after the user clicks/submits the form on the portal.

 

Thanks

@newmay 

 

In your Entity Form or Web form, you can use the below:

$("#fieldschemaname").val(true);
If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Fubar
Solution Sage
Solution Sage

If the issues was just that you couldn't get Metadata to set it, it is possible you tried setting it 0/1 rather than true/false (Boolean wont take an index number like other option sets do).

 

Note: you can set it using JavaScript as suggested by Mira if the field is on the form and editable (hint: you may need to hide it with CSS or jQuery if you don't wan the user to see it)

HI @Mira_Ghaly thanks for reaching out!

 

I put the code with the fieldname into the Custom Javascript section within the "Additional Settings" Tab.  

newmay_2-1634125357260.png

 

newmay_1-1634125158344.png

 

Yet it is still on the Profile Web Form 

newmay_3-1634125389396.png

 

 

@Fubar Hi I did as Mira suggested! Yet no change. 

newmay_0-1634125608386.png

 

Did I forget something here?

Gwham
Helper I
Helper I

Your field is a two option, so it's likely you will have to select the relevant option via jQuery instead of setting a text value. You should also be able to set this via meta data. Try true/false if 1/0 did not work.

 

 

Hi @newmay 

 

Please use below code:

$("#bbg_approved").prop("checked", false);
$("#bbg_approved").closest("td").hide();

 

--------------------------
If you like this post, give a Thumbs up. Where it solved your query, Mark as a Solution so it can help other people!

Hey @hardikv that worked thanks!!!!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (1,750)