Tuesday 24 January 2017

Redirect to any other views or URL right after creation of an item in Sharepoint list new spform

//For redirecting
//Buton Save event
//this is only working if we use the default save button
//if we change the default save button to our custom button write these code on our custom buton event
fd.onsubmit(function() {
//Identify the typereg value
//Choice field or lookup field value
var typeRegValue=fd.field('Typereg').control()._el().find('select option:selected').text();
   if(typeregValue==Test)
   {
   //we can redirect to any list
     fd.sourceFormParam('/Lists/MyList/Test.aspx');
  
   }
   if(typeregValue==Test1)
   {
     fd.sourceFormParam('/Lists/MyList/Test1.aspx');
   }
   else
   {
     fd.sourceFormParam('/Lists/MyList/AllItems.aspx');
   }
    return true;
});

///
//If you want redirect to the edit form of the current saved item right after the creation
//Use below code
fd.onsubmit(function() {
  var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'fd_Item_Edit.aspx?ID=');
  fd.sourceFormParam(uri);
  return true;
});

No comments:

Post a Comment