Skip to main content
added 1 character in body
Source Link
LZ_MSFT
  • 6.2k
  • 1
  • 8
  • 7
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                if(mySection!=null){
                    getFileName(mySection);
                }                               
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages''Site Pages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                if(mySection!=null){
                    getFileName(mySection);
                }                               
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                if(mySection!=null){
                    getFileName(mySection);
                }                               
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('Site Pages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
added 40 characters in body
Source Link
LZ_MSFT
  • 6.2k
  • 1
  • 8
  • 7
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                if(mySection!=null){
                    getFileName(mySection);
                }                               
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                getFileName(mySection);             
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                if(mySection!=null){
                    getFileName(mySection);
                }                               
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>
Source Link
LZ_MSFT
  • 6.2k
  • 1
  • 8
  • 7

Use the following code to check if it works.

<script src="//code.jquery.com/jquery-3.2.1.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
    var currentUserEmail = _spPageContextInfo.userEmail;

    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('StaffDirectory')/Items?$filter=Title eq '" + currentUserEmail + "'&$select=Section";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var mySection = data.d.results[0].Section;
                getFileName(mySection);             
            }       
        },
        error: function () {
            alert("error found");
        }
    });
});
function getFileName(mySection){
    // begin work to call across network
    var requestUri = _spPageContextInfo.webAbsoluteUrl +
                  "/_api/web/Lists/getByTitle('SitePages')/Items?$filter=Section eq '" + mySection + "'&$select=FileLeafRef";

    // execute AJAX request
    $.ajax({
        url: requestUri,
        type: "GET",
        headers: { "ACCEPT": "application/json;odata=verbose" },
        success: function (data) {
            if(data.d.results.length>0){
                var CalFileName = data.d.results[0].FileLeafRef;
                alert(CalFileName);
            }       
        },
        error: function () {
            alert("Calendar not found");
        }
    });
}
</script>