My friendly CRM Helpers. I am trying to fix an issue with javascript and would love to have your assistance. The first group of code works and sets the subject but overwrites the title if it is already entered by the user. I am trying to fix the code to not overwrite the subject if it is already there and only set it if it does not exist. However in my code below there seems to be an error and I can not seem to find where.
Code that works
function SetHealthFairSubject() { var separator = ' - '; var regarding = Xrm.Page.data.entity.attributes.get("regardingobjectid").getValue()[0].name; var date = Xrm.Page.getAttribute("scheduledstart").getValue().toDateString();; var subject = Xrm.Page.getAttribute("subject").getValue(); if (subject == null); Xrm.Page.getAttribute("subject").setValue(regarding + separator + "Health Fair Date" + separator + date); }Code that does not
function SetHealthFairSubject() { var separator = ' - '; var regarding = Xrm.Page.data.entity.attributes.get("regardingobjectid").getValue()[0].name; var date = Xrm.Page.getAttribute("scheduledstart").getValue().toDateString();; var subject = Xrm.Page.getAttribute("subject").getValue(); if (subject != null); {subject = subject;} else { if (subject == null); {Xrm.Page.getAttribute("subject").setValue(regarding + separator + "Health Fair Date" + separator + date);} } }