Skip to main content

Notifications

Power Pages - Power Apps Portals
Answered

Changing field value when editing record

Posted on by 118

Hi,


I am trying to change a fields value after a user edits the record through an edit form. This field is not a lookup field linked to a relationship, it's a simple field. This field won't be accessible or visible in this edit form. It seems like through JavaScript could be an option, running some code when the user clicks the save button, but I would like not to have to check if the form is actually going to save the record or if it's going to encounter some validation error.

 

Is there a simpler option?

 

Thanks in advance.

  • Verified answer
    oliver.rodrigues Profile Picture
    oliver.rodrigues 8,830 on at
    Re: Changing field value when editing record

    Hi, I am just wondering what is the User().Email in your code, is that a custom object in your JS or something?

    Can you try the following code? 

     

     

     

    $(document).ready(function() {
    
     var email = "{{ user.emailaddress1 }}";
     console.log("Email: " + email);
    
     $("#cr027_useremail").val(email);
    });
  • MS5 Profile Picture
    MS5 118 on at
    Re: Changing field value when editing record

    Hi @OliverRodrigues ,

     

    The value is dynamic, I have tried putting this code in the custom JavaScript with no luck:

     

    $(document).ready(function() {
    $("#cr027_useremail").val(User().Email);
    });

     

    What am I doing wrong?

     

    Thanks.

  • oliver.rodrigues Profile Picture
    oliver.rodrigues 8,830 on at
    Re: Changing field value when editing record

    if you want a static value you can use the entity form metadata: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/configure-web-form-metadata#set-value-on-save

     

    if the value is dynamic, you can set through JS 

    to add client-side validation follow this documentation: https://docs.microsoft.com/en-us/powerapps/maker/portals/configure/add-custom-javascript#additional-client-side-field-validation

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

October 2024 Newsletter…

October 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #4 How to Conntact Support…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 142,733

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 63,750

Leaderboard