Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Create URL from a number of fields using javascript

$
0
0

Hi!

I am trying to create a URL field based on a number of fields within any given company page. The main problem i am encountering is when trying to add the primary contact of a company to the string. It resolves to object Object instead of the name of the contact. Is thier anyway to pull the name of the contact that is recorded within a company? Below is my current JS

function CreateURL() {

var employeeEmail = Xrm.Page.data.entity.attributes.get("mc_nutraceuticalsowner").getValue();
var distributor = Xrm.Page.data.entity.attributes.get("mc_distributorforms").getValue();
var pharmacyName = Xrm.Page.data.entity.attributes.get("name").getValue();
var pharmacyAccountNumber = Xrm.Page.data.entity.attributes.get("mc_membershipnumber").getValue();
var state = Xrm.Page.data.entity.attributes.get("mc_stateforms").getValue();
var customerContactName = Xrm.Page.data.entity.attributes.get("primarycontactid").getValue();

var accountUrl = "https://forms.example.com/view.php?element_279="+employeeEmail+"&element_5="+distributor+"&element_34="+pharmacyName+"&element_33="+pharmacyAccountNumber+"&element_51="+state+"&element_280="+customerContactName+"&id=20314";

Xrm.Page.data.entity.attributes.get("mc_accounturl").setValue(accountUrl);

}

The current URL being given from the script is: 

https://forms.example.com/view.php?element_279=%5bobject%20Object%5d&element_280=%5bobject%20Object%5d&element_33=1111111&element_34=Medlab%20Clinical%20LTD&element_5=3&element_51=1


Viewing all articles
Browse latest Browse all 79901

Trending Articles



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