0

I'm trying to bring the value(Title) of an event to another form in SharePoint.

So it's basically a register form. When someone clicks an event, you can click a button "Register" and it brings you to another form where you can complete the registration.

I've been able to get the id of the event but not the values for some reason. Everything was done in JQuery.

Any help would be much appreciated.

=====Code to retrieve Title====

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

<script type="text/javascript">

jQuery(document).ready(function($) {

    //get the Product name from they query string
    var ProductName = getParameterByName("ProductName");

    //Set the corresponding Lookup field value to the Product name
    $("select[title='Title']").val(ProductName);    

});

function getParameterByName(name)
{
  name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
  var regexS = "[\\?&]" + name + "=([^&#]*)";
  var regex = new RegExp(regexS);
  var results = regex.exec(window.location.href);
  if(results == null)
    return "";
  else
    return decodeURIComponent(results[1].replace(/\+/g, " "));
}

</script>
0

First of all, use the lookup from Events list to the list where you are saving the registrations.

You can use any of the following solutions:

  1. On registration form, you will have one dropdown to choose the event, which will have event ID as a value and event Title as a display text. So you can set the value of dropdown to the event ID you are getting from query string.

  2. If you are able to get the item ID from event list and you want more details of that event, use REST api to fetch that event using following code:

function getListItem(url, listname, eventId) { // Getting our list items $.ajax({ url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle("'+ listname +'")/items(" + eventId + ")/$select=Title", method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { // Returning the results }, error: function (error) { console.log(error); } }); }

In $select, you can add more columns(comma-separated) if you want to get additional details from Events list.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.