Reputation: 868
For some reason the endDate of positions are hanging the whole script?
function importJobsEducation() {
IN.API.Profile("me")
.fields(["id","positions:(company,title,summary,start-date,end-date,is-current)", "educations","skills", "headline"])
.result(function(result) {
profile = result.values[0];
$("#headline").val(profile.headline);
$("#linkedInID").val(profile.id)
positions = "";
for (var index=0; index < profile.positions.values.length; index++) {
JobTitle = profile.positions.values[index].title
jobSummary = profile.positions.values[index].summary
isCurrent = profile.positions.values[index].isCurrent
JstartMDate = profile.positions.values[index].startDate.month
JstartYDate = profile.positions.values[index].startDate.year
alert(profile.positions.values[index].endDate.month)
if (isCurrent === false) {
}
// Company Fields
OrgName = profile.positions.values[index].company.name
companyType = profile.positions.values[index].company.companyType
size = profile.positions.values[index].company.size
industry = profile.positions.values[index].company.industry
ticker = profile.positions.values[index].company.ticker
}
education = "";
for (var index=0; index < profile.educations.values.length; index++) {
schoolName = profile.educations.values[index].schoolName
startDate = profile.educations.values[index].startDate.year
EndDate = profile.educations.values[index].endDate.year
}
skills = "";
for (var index=0; index < profile.skills.values.length; index++) {
skills += '<a href="" class="tag">'+ profile.skills.values[index].skill.name + '</a> ';
}
});
}
Upvotes: 1
Views: 886
Reputation: 2109
The problem with your code is that current positions do not have an end date, and the way your code is written tries to fetch the endDate even for current positions.
Therefore, I suggest you have a conditional tag which check if this position is current, and if it isn't it fetches the end date. Example:
if (profile.positions.values[index].isCurrent === false) {
endDate = profile.positions.values[index].endDate.month;
}
I hope this helps.
Upvotes: 1