Quantcast
Channel: CRM Development 論壇
Viewing all articles
Browse latest Browse all 10280

Auto-populate field JavaScript Basics Question

$
0
0

Hello CRM community,

I am pretty new to writing JavaScript and extending CRM. I was self learning pretty well just from other posts and the SDK but am now trying to write a piece of code to auto-populate a field based upon the input of another. I am really struggling with this. For the sake of making it easy on anyone willing to help I will use all standard fields (Relationship Type and Credit Limit) and entities.

Scenario: On the account form, I want the Relationship Type field value to auto-populate a dollar amount in the Credit Limit field

If Relationship Type = Supplier, then Credit Limit should be 0

If Relationship Type = Vendor, then Credit Limit should be 1000

If Relationship Type = Anything else in drop down list, then do nothing (I am yet to find how to tell javascript to do nothing

Below was my best attempt although I am sure it is littered with errors

function populate_credithold()

{

  if (Xrm.Page.getAttribute("customertypecode").getValue() == ("Supplier"))

      {

        (Xrm.Page.getAttribute("creditlimit").setValue("0"))

    }

   else{       

    (Xrm.Page.getAttribute("customertypecode").getValue() == ("Vendor"))

        {

        (Xrm.Page.getAttribute("creditlimit").setValue("1000"))

        }

    }

    else{       

    (Xrm.Page.getAttribute("customertypecode").getValue() != (does not equal supplier or vendor)

        {

        (Xrm.Page.getAttribute("creditlimit").setValue(This is where i want it todo nothing))

        }

    }

}

Can anyone please help a noobie JavaScript writer out?

Thank you in advance


Viewing all articles
Browse latest Browse all 10280

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>