I am trying to customize certain fields in our MS Dynamics CRM and I'd like to ask whether you guys can tell me my the error in my code. Basically we have a Contact and there we have 3 Adresses. 1 correspondence adress which takes the values of the private or the work adress. What i would like to achieve is that, if you set our field manually to "no adress available", that we have a pop-up to inform us, that we have some data in either the P or W adress:
I am trying to get the values first and then check them if they contain some values. It is only one function. I am definitely a beginner, so any input is appreciated :)
That is how i tried it:
function CheckKorrespondenzAdresse() {
var korrespondenzadresse1 = Xrm.Page.getAttribute("new_correspondece_adress").getValue(); //get the Koresspondenzadresse value
var pplz = Xrm.Page.getAttribute("new_address3_postalcode").getValue(); //get the P-PLZ value
var port = Xrm.Page.getAttribute("new_address3_city").getValue(); //get the P-Ort value
var gplz = Xrm.Page.getAttribute("address2_postalcode").getValue(); //get the G-PLZ value
var gort = Xrm.Page.getAttribute("address2_city").getValue(); //get the G-Ort value
if (korrespondenzadresse1 == '100000002' | pplz != null | port != null) {
confirm("P Adresse enthält Daten! Korrespondenzadresse wird darum auf Privatadresse geändert!"); //User benachrichtigen, dass Feld Daten enthält
Xrm.Page.getAttribute("new_correspondece_adress").setValue(100000000); //Korrespondenzadresse auf Privatadresse ändern
}
else if (korrespondenzadresse1 == '100000002' | gplz != null | gort != null) {
confirm("G Adresse enthält Daten! Korrespondenzadresse wird darum auf Geschäftsadresse geändert!"); //User benachrichtigen, dass Feld Daten enthält
Xrm.Page.getAttribute("new_correspondece_adress").setValue(100000001); //Korrespondenzadresse auf Geschäftsadresse ändern
}
}
Aucun commentaire:
Enregistrer un commentaire