Skip to content

Instantly share code, notes, and snippets.

@emerham
Last active February 4, 2020 00:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emerham/5734a1888dc9f442dfef368134602752 to your computer and use it in GitHub Desktop.
Save emerham/5734a1888dc9f442dfef368134602752 to your computer and use it in GitHub Desktop.
<script>
Qualtrics.SurveyEngine.addOnload(function() {
/*Place your JavaScript here to run when the page loads*/
submitRFI();
});
function submitRFI() {
// Variable for specific Salesforce instances
const env = "osu.secure";
// const env = "sandboxjme-osu.cs9";
// Construct the request
const xhttp = new XMLHttpRequest();
// Notify the user of result of the request
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.getResponseText);
}
};
// Open the request via the API endpoint URI
xhttp.open("POST", "https://" + env + ".force.com/forms/services/apexrest/ugradrfi/ugradinq:noemail", true);
xhttp.setRequestHeader("Content-type", "application/json");
// Send the request
xhttp.send(JSON.stringify(jsonData));
}
// Make a term code out of year and text term.
let startingTerm = '';
let termYear = parseInt("${q://QID33/ChoiceTextEntryValue}");
switch ("${q://QID40/ChoiceGroup/SelectedChoices}") {
case "Summer":
startingTerm = termYear + 1 + "00";
break;
case "Fall":
startingTerm = termYear + 1 + "01";
break;
case "Winter":
startingTerm = termYear + "02";
break;
case "Spring":
startingTerm = termYear + "03";
break;
}
// Setup matching for the Major codes needed in the backend to the human readable text frontend.
let majorCode = "";
switch ("${q://QID12/ChoiceGroup/SelectedChoices}") {
case "American Studies":
majorCode = "865";
break;
case "Art":
majorCode = "880"
break;
case "Arts, Media and Technology":
majorCode = "907"
break;
case "Biology":
majorCode = "509";
break;
case "Business Administration":
majorCode = "180";
break;
case "Computer Science":
majorCode = "307";
break;
case "Elementary Education":
majorCode = "260";
break;
case "Energy Systems Engineering":
majorCode = "293";
break;
case "Environmental Sciences":
majorCode = "657";
break;
case "Hospitality Management":
majorCode = "291";
break;
case "Human Development and Family Sciences":
majorCode = "447";
break;
case "Kinesiology":
majorCode = "840";
break;
case "Liberal Studies":
majorCode = "920";
break;
case "Natural Resources":
majorCode = "671";
break;
case "Psychology":
majorCode = "965";
break;
case "Social Science":
majorCode = "286";
break;
case "Sustainability":
majorCode = "870";
break;
case "Tourism and Outdoor Leadership":
majorCode = "872";
break;
case "Undecided - University Exploratory Studies Program":
majorCode = "800";
break;
default:
majorCode = "800";
}
let sourcecode = '';
switch ("${q://QID18/ChoiceGroup/SelectedChoices}") {
case 1:
case 2:
case 3:
sourcecode = 'CQ1';
break;
case 4:
case 5:
sourcecode = 'CQ5';
break;
default:
sourcecode = 'CQ';
}
// Create the date of birth from our mm/dd/yyy to yyyy-mm-dd.
let myDob = "${q://QID32/ChoiceTextEntryValue}";
let splitDate = myDob.split("/");
// Create a payload object to send to the backend.
let jsonData = {
data: [{
firstname: "${q://QID29/ChoiceTextEntryValue}",
lastname: "${q://QID30/ChoiceTextEntryValue}",
email: "${q://QID31/ChoiceTextEntryValue}",
major: majorCode,
degree: "BS",
interest: "",
campus: "B",
term: startingTerm,
dob: splitDate[2] + "-" + splitDate[0] + "-" + splitDate[1],
sourcecode: sourcecode,
more: [{
"apiname": "ugradinq-studentLevel-PL",
"response": "01"
},
{
"apiname": "ugradinq-studentType-PL",
"response": "1"
}
]
}]
};
</script>
<div style="text-align: center;"><span style="font-size:22px;">Thanks, ${q://QID29/ChoiceTextEntryValue}</span><span style="font-size:22px;">!</span><br />
<strong>Share this survey with your friends</strong><br />
<br />
<iframe allow="encrypted-media" allowtransparency="true" frameborder="0" height="28" scrolling="no" src="https://www.facebook.com/plugins/share_button.php?href=https%3A%2F%2Fosucascades.edu%2Ffit&amp;layout=button&amp;size=large&amp;width=73&amp;height=28&amp;appId"
style="border:none;overflow:hidden" width="73"></iframe><br />
<a class="twitter-share-button" data-show-count="false" data-size="large" data-text="I just took the Fit Quiz at OSU-Cascades. See if OSU-Cascades is a fit for you." data-url="https://osucascades.edu/fit" href="https://twitter.com/share?ref_src=twsrc%5Etfw">Tweet</a>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</div>
Qualtrics.SurveyEngine.addOnload(function() {
/*Place your JavaScript here to run when the page loads*/
submitRFI();
});
Qualtrics.SurveyEngine.addOnReady(function() {
/*Place your JavaScript here to run when the page is fully displayed*/
});
Qualtrics.SurveyEngine.addOnUnload(function() {
/*Place your JavaScript here to run when the page is unloaded*/
});
function submitRFI() {
// Variable for specific Salesforce instances
const env = "osu.secure";
// const env = "sandboxjme-osu.cs9";
// Construct the request
const xhttp = new XMLHttpRequest();
// Notify the user of result of the request
xhttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
console.log(this.getResponseText);
}
};
// Open the request via the API endpoint URI
xhttp.open("POST", "https://" + env + ".force.com/forms/services/apexrest/ugradrfi/ugradinq", true);
xhttp.setRequestHeader("Content-type", "application/json");
// Send the request
xhttp.send(JSON.stringify(jsonData));
}
// Make a term code out of year and text term.
let startingTerm = '';
let termYear = parseInt("${q://QID33/ChoiceTextEntryValue}");
switch ("${q://QID40/ChoiceGroup/SelectedChoices}") {
case "Summer":
startingTerm = termYear + 1 + "00";
break;
case "Fall":
startingTerm = termYear + 1 + "01";
break;
case "Winter":
startingTerm = termYear + "02";
break;
case "Spring":
startingTerm = termYear + "03";
break;
}
// Setup matching for the Major codes needed in the backend to the human readable text frontend.
let majorCode = "";
switch ("${q://QID12/ChoiceGroup/SelectedChoices}") {
case "American Studies":
majorCode = "865";
break;
case "Art":
majorCode = "880"
break;
case "Arts, Media and Technology":
majorCode = "907"
break;
case "Biology":
majorCode = "509";
break;
case "Business Administration":
majorCode = "180";
break;
case "Computer Science":
majorCode = "307";
break;
case "Elementary Education":
majorCode = "260";
break;
case "Energy Systems Engineering":
majorCode = "293";
break;
case "Environmental Sciences":
majorCode = "657";
break;
case "Hospitality Management":
majorCode = "291";
break;
case "Human Development and Family Sciences":
majorCode = "447";
break;
case "Kinesiology":
majorCode = "840";
break;
case "Liberal Studies":
majorCode = "920";
break;
case "Natural Resources":
majorCode = "671";
break;
case "Psychology":
majorCode = "965";
break;
case "Social Science":
majorCode = "286";
break;
case "Sustainability":
majorCode = "870";
break;
case "Tourism and Outdoor Leadership":
majorCode = "872";
break;
case "Undecided - University Exploratory Studies Program":
majorCode = "800";
break;
default:
majorCode = "800";
}
// Create the date of birth from our mm/dd/yyy to yyyy-mm-dd.
let myDob = "${q://QID32/ChoiceTextEntryValue}";
let splitDate = myDob.split("/");
// Create a payload object to send to the backend.
let jsonData = {
data: [{
firstname: "${q://QID29/ChoiceTextEntryValue}",
lastname: "${q://QID30/ChoiceTextEntryValue}",
email: "${q://QID31/ChoiceTextEntryValue}",
major: majorCode,
degree: "BS",
interest: "",
campus: "B",
term: startingTerm,
dob: splitDate[2] + "-" + splitDate[0] + "-" + splitDate[1],
sourcecode: "CQ",
more: [{
"apiname": "ugradinq-studentLevel-PL",
"response": "01"
}, {
"apiname": "ugradinq-studentType-PL",
"response": "1"
}]
}]
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment