function PopulateActivityFromSvcActivityCustomer()
{
debugger;
// Fields on the Service Activity Page...
var Subject = "subject";
var SubjectField = Xrm.Page.getAttribute(Subject);
var ProgramArea = "ec_programarea";
var ProgramAreaField = Xrm.Page.getAttribute(ProgramArea);
var Service = "serviceid";
var the_service = Xrm.Page.getAttribute(Service).getValue();
var Svc_Act_Customer = "customers";
var Svc_Act_CustomerValue = Xrm.Page.getAttribute(Svc_Act_Customer).getValue();
var ActivityType = "ec_activitytype";
var ActivityTypeField = Xrm.Page.getAttribute(ActivityType);
// Activity Type Values
var Orientation = 1;
var Certification = 2;
var Other = 3;
var ABAWD = 200000000;
// Program Area Values
var SNAP = 1;
var TA = 2;
var MA = 3;
var LTC = 4;
var HEAP = 948180000;
var Homeless = 948180001;
var EmergencySvcs = 948180002;
var ServiceActivityTab = Xrm.Page.ui.tabs.get("service");
var SNAP_Office_Section_Name = "service_section_3";
var SNAP_Office_Section = ServiceActivityTab.sections.get(SNAP_Office_Section_Name);
// Create new array to hold customer info
var customer_name = Svc_Act_CustomerValue[0].name; //name of customer
var customer_id = Svc_Act_CustomerValue[0].id; //guid of customer
var customer_entityType = Svc_Act_CustomerValue[0].entityType; //entity schema name of customer
// Set Activity Values
if (the_service == null)
{
var description = customer_name + " Appointment";
var AT = Other;
var PA = "";
}
else
{
// Create new array to hold service info
var the_service_name = the_service[0].name; //name of service
var the_service_id = the_service[0].id; //guid of service
var the_service_entityType = the_service[0].entityType; //entity schema name of service
if (the_service_name == "LTC Appointment")
{
var description = customer_name + " LTC Appt";
var AT = Certification;
var PA = LTC;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "MA Wed Interview")
{
var description = customer_name + " MA Wed Interview";
var AT = Certification;
var PA = MA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "SNAP Expedite Service")
{
var description = customer_name + " SNAP Exp Appt";
var AT = Certification;
var PA = SNAP;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "SNAP Service")
{
var description = customer_name + " SNAP Appt";
var AT = Certification;
var PA = SNAP;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "TA EFP CERT")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA EFP CERT Refugee")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA EFP CERT Spanish")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA EFP EXPEDITE")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA EFP Homeless")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA Orientation")
{
var description = customer_name + " Orientation";
var AT = Orientation;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA TAS")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA TAS CERT EXPEDITE")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA TAS CERT Spanish")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA TTW INC")
{
var description = customer_name + " Cert Appt";
var AT = Certification;
var PA = TA;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "SNAP ABAWD")
{
var description = customer_name + " SNAP ABAWD Appt";
var AT = ABAWD;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "ABAWD NTA-SNAP Information Session")
{
var description = customer_name + " ABAWD NTA-SNAP Information Appt";
var AT = ABAWD;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "ABAWD NTA-SNAP Re-Establishment Session")
{
var description = customer_name + " ABAWD NTA-SNAP Re-Establishment Appt";
var AT = ABAWD;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "ABAWD-TA Re-Establishment Session")
{
var description = customer_name + " ABAWD-TA Re-Establishment Appt";
var AT = ABAWD;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "ABAWD Job Search Appointment")
{
var description = customer_name + " ABAWD Appt";
var AT = ABAWD;
SNAP_Office_Section.setVisible(true);
}
else if (the_service_name == "TA CERT Expedite")
{
var description = customer_name + " TA Cert Exp Appt";
var AT = Certification;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA CERT Expedite Spanish")
{
var description = customer_name + " TA Cert Exp Appt - Spanish";
var AT = Certification;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "TA Skype CERT")
{
var description = customer_name + " TA Skype CERT Interview";
var AT = Certification;
SNAP_Office_Section.setVisible(false);
}
else if (the_service_name == "")
{
var description = customer_name + " XXXXXXX";
var AT = Other;
var PA = "";
SNAP_Office_Section.setVisible(false);
}
} //end "if (the_service != null)"
// Setting field values based on the Service chosen by the worker.
SubjectField.setValue(description);
ProgramAreaField.setValue(PA);
ActivityTypeField.setValue(AT);
} // end of function PopulateActivityFromCustomer