Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Get and set information into a text field througth web resource

Posted on by Microsoft Employee

I am trying to add a web resource in a form, this web resource is only one button, and when I click on it, it has to get the information into a field and set in another field but doesn't work, can you help me?

<html>
    <head>
        <style>
                .myButton {
                    -moz-box-shadow:inset 0px 1px 0px 0px #54a3f7;
                    -webkit-box-shadow:inset 0px 1px 0px 0px #54a3f7;
                    box-shadow:inset 0px 1px 0px 0px #54a3f7;
                    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #007dc1), color-stop(1, #0061a7));
                    background:-moz-linear-gradient(top, #007dc1 5%, #0061a7 100%);
                    background:-webkit-linear-gradient(top, #007dc1 5%, #0061a7 100%);
                    background:-o-linear-gradient(top, #007dc1 5%, #0061a7 100%);
                    background:-ms-linear-gradient(top, #007dc1 5%, #0061a7 100%);
                    background:linear-gradient(to bottom, #007dc1 5%, #0061a7 100%);
                    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#007dc1', endColorstr='#0061a7',GradientType=0);
                    background-color:#007dc1;
                    -moz-border-radius:3px;
                    -webkit-border-radius:3px;
                    border-radius:3px;
                    border:1px solid #124d77;
                    display:inline-block;
                    cursor:pointer;
                    color:;
                    font-family:Arial;
                    font-size:13px;
                    padding:6px 24px;
                    text-decoration:none;
                    text-shadow:0px 1px 0px #154682;
                }
                .myButton:hover {
                    background:-webkit-gradient(linear, left top, left bottom, color-stop(0.05, #0061a7), color-stop(1, #007dc1));
                    background:-moz-linear-gradient(top, #0061a7 5%, #007dc1 100%);
                    background:-webkit-linear-gradient(top, #0061a7 5%, #007dc1 100%);
                    background:-o-linear-gradient(top, #0061a7 5%, #007dc1 100%);
                    background:-ms-linear-gradient(top, #0061a7 5%, #007dc1 100%);
                    background:linear-gradient(to bottom, #0061a7 5%, #007dc1 100%);
                    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#0061a7', endColorstr='#007dc1',GradientType=0);
                    background-color:#0061a7;
                }
                .myButton:active {
                    position:relative;
                    top:1px;
                }
        </style>
    <meta><meta></head>
<body style="word-wrap: break-word;">
<button type="button" class="myButton" onclick="GenerarRFC();">Generar RFC</button>
 <script>
        function GenerarRFC(){
            try{

                var apellido = parent.Xrm.Page.getAttribute("new_lastname").getValue();
                parent.Xrm.Page.getAttribute("new_profesion").setValue(apellido);  
                }
            }catch(err){
                console.log("error "+err.message);
            }
        }
</script>
</body></html>

*This post is locked for comments

  • Verified answer
    shivaram Profile Picture
    shivaram 3,315 on at
    RE: Get and set information into a text field througth web resource

    Hi Lues,

    I used like following code and it works for me

    <html>

    <head>

    <script>

    function getAttribute(){

    window.parent.Xrm.Page.getAttribute("new_destinationfield").setValue(window.parent.Xrm.Page.getAttribute("new_sourcefield").getValue());

    }

    </script>

    </head>

    <body>

    <input type="button" value="Get and Set" onclick="getAttribute()"/>

    </body>

    </html>

    Hope this is useful for you

    Thanks,

    Shiva

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Get and set information into a text field througth web resource

    Hi Luis,

    Please try the following code.

    <script>
         function GenerarRFC(){
           try{
               var apellido = window.parent.Xrm.Page.getAttribute("new_lastname").getValue();
               window.parent.Xrm.Page.getAttribute("new_profesion").setValue(apellido);   
              }
              catch(err){
                    console.log("error "+err.message);
           }
         }
    </script>

    Also write the script in the head section of html.

  • Suggested answer
    PS Profile Picture
    PS 23,577 on at
    RE: Get and set information into a text field througth web resource

    You should use ribbon workbench and apply the javascript mentioned in following URLs on your button:

    stackoverflow.com/.../copying-value-from-one-input-field-to-another-input-field

    kbase.icbconsulting.com/.../set-value-of-a-field-equal-to-another-field-in-microsoft-crm

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans