SharePoint Redirect after post - sharepoint

My SharePoint input tag is using an XSLT variable for the redirect. I would like to substitute it for a javascript function to determine the value of the users input. Is this possible from within this tag? If not is possible to run a javascript function from within as XSLT variable? The following article show that something like this is possible but I need an example. http://www.nothingbutsharepoint.com/2011/05/05/extending-the-dvwp-passing-xsl-variables-to-javascript-aspx/
Thank you in advance.
<input type="button" id="Submit" value=" Submit " style="width:100px" onclick="javascript: if(!PreSaveItem()) return false;{ddwrt:GenFireServerEvent(concat('__commit;__redirect={',$RedirectLoc,'}'))}"/>

Basically behind GenFireServerEvent is a __doPostBack function.
__doPostBack('elementgeneratedname','__redirect={' + value '}');
Take a look into the browser what code is generated and use it in your function. Most probably first argument is not the id of the button and is the name of the web part container (somthing like 'ctl00$PlaceHolderMain$WebPartId').

Related

Signify for view to search for next task url

I am asking if there is a prefered method of making get_next_task_url() redirect to the next process url. get_next_task_url() looks for _continue in request.POST however the POST object is not able to be modified.
Currently i am adding a hidden field into my form:
<input id="continue" type="hidden" name="_continue" value="true">
Is there a variable that i can set within the views or flow classes to achieve the same thing?
Viewflow is the thin workflow layer on top of usual django views.
As for usual django views, to set redirect url can redefine get_success_url in your code
http://ccbv.co.uk/projects/Django/3.0/django.views.generic.edit/FormMixin/#get_success_url

Multiple conflicting route parameter formats in Razor Pages

I'm making simple crud forms based on the tutorials for Razor Pages MVVM - https://learn.microsoft.com/en-us/aspnet/core/tutorials/razor-pages/?view=aspnetcore-2.1
The issue is the elements on the Index page use different formats for the route parameter and I end up with URL's like /StockIndexMonths/2?StockIndexId=1
Where both /2 and StockIndexId=1 are the same parameter
The select list will use ?StockIndexId=1
The Create New link will use /1, when returning to the Index /1 is used
If I use the select list again I get both /1?StockIndexId=2
Can anyone tell me the preferred way to force the same parameter format to be used? I'm trying to keep Razor Pages doing it's 'magic'
Index.cshtml
#page "{StockIndexId?}"
#model Investments.Pages.StockIndexMonths.IndexModel
#{
ViewData["Title"] = "Index";
}
<h2>Index</h2>
<form>
<select asp-for="StockIndexId" asp-items="Model.StockIndexNameSelect" onchange="this.form.submit();"></select>
</form>
<a asp-page="Create" asp-route-StockIndexId="#Model.StockIndexId">Create New</a>
<table class="table">
...
Alter the form tag so that it uses the POST method:
<form method="post">
Currently, because the method is not specified, GET is used by default, which appends forms values to the URL as query string values. That's why you see what you are seeing.

Trouble handling hidden element with selenium

Every time I run this code, I get an issue reaching to the targeted page. The site requires post request parameter to be filled in to reach the page where I am after. However, using get request it was good to go until it hits "Var4" parameter within my code. Inspecting element I could see that it indicates as hidden. If i left the hidden parameter blank then it redirects to another location. So, satisfying this thing to get to the targeted page is beyond my capability. Any suggestion will be appreciated.
from selenium import webdriver
driver = webdriver.Chrome(r"C:\Users\ar\Desktop\Chromedriver\chromedriver.exe")
driver.get('https://www.infocomm.org/cps/rde/xchg/infocomm/hs.xsl/memberdirectory.htm')
Var1='Professional Services Providers'
Var2='AUSTRALIA'
Var3='0'
Var4='1'
driver.find_element_by_xpath('//select[#name="mas_type"]').send_keys(Var1)
driver.find_element_by_xpath('//select[#name="mas_cntr"]').send_keys(Var2)
driver.find_element_by_xpath('//input[#name="OtherCriteria"]').send_keys(Var3)
driver.find_element_by_xpath('//input[#name="DoMemberSearch"]').send_keys(Var4)
driver.find_element_by_xpath('//input[#type="submit"]').click()
Element for the hidden stuffs which should be applicable for "Var4":
<form name="searchform" id="searchform" action="memberdirectory.htm" method="post" onsubmit="return Checkform();">
<input type="hidden" id="DoMemberSearch" name="DoMemberSearch" value="1">
<div class="login block-type-a block">
As workaround, you can try execute javascript with selenium.
For example, to unhide element
driver.execute_script("document.getElementById('DoMemberSearch').type = 'text';")
or set value directly
driver.execute_script("document.getElementById('DoMemberSearch').value = '%s';" % Var4)
you could not sendkeys to a hidden element, what you can do is to use javascript to send the value
probably something like this
driver.execute_script("document.getElementById('DoMemberSearch').value='1')

Passing list as multiple parameter URL in snap

Is it possible to pass list parameter from browser to a handler function in Snap?
How do I construct a multiple parameters URL from a list and send it to a handler function?
For instance, I need to delete some table rows or any other objects.
I can not do it with the usual REST route:
("/objects/:id", method DELETE deleteObject)
simply because there could be too many and deleting 100 rows one by one can get a bit tedious.
I chose the doomed objects via checkbox input, say [3,4,6,8] rows need to be deleted.
So how do I pass that list to the handler within URL and what would route look like for the action ?
UPDATE
Well, I finally did it with jquery and ajax call.
Snap's "getParams" function can process multiple parameters URL but I still cannot figure out how to actually construct the URL without jquery and ajax.
I used javascript to collect the items to be deleted and build the array of the items.
I then used ajax to construct multiple parameters URL and send it to the handler.
Few things to note with this method and Snap:
-- Snaps's "getParams" function only supports old style multiple parameters URL:
"a=1&a=2&a=3&a=4"
and not the new one:
"a[]=1&a[]=2&a[]=3&a[]=4"
which makes passing complex parameters impossible.
-- The route should be:
("/objects/", method DELETE deleteObject)
and not the:
("/objects/:ids", method DELETE deleteObject)
I did not answer my question because I don't believe it is the only way to pass multiple parameters URL with snap.
Although "getParams" can process it, my question still stays: how do I construct the URL and send it off to a handler?
For instance, Rails uses "link_to" function within view logic to construct the URL. Snap does not use any logic inside templates so how does it work then?
It just can't be that the only way to pass multiple parameters URL in snap is with the help of javascript...?
Please someone confirm this for me?
You're pretty much there. The following form...
<form action="/foo">
<ul>
<li>Row 1: <input type="checkbox" name="a" value="1"/></li>
<li>Row 2: <input type="checkbox" name="a" value="2"/></li>
<li>Row 3: <input type="checkbox" name="a" value="3"/></li>
<li>Row 4: <input type="checkbox" name="a" value="4"/></li>
<li>Row 5: <input type="checkbox" name="a" value="5"/></li>
</ul>
<input type="submit" name="submit" value="Submit"/>
</form>
...gets submitted like this.
http://localhost:8000/foo?a=2&a=3&a=5&submit=Submit
Then, inside your handler, this will get you a list of ByteStrings.
fooHandler = do
as <- getsRequest (rqParam "a")
So this doesn't require JavaScript at all. But it works with JavaScript as well. If you use jQuery to submit a list like this...
var fieldData = { rows: [0,1,4], cols: [2,3,5] };
$.getJSON('http://localhost:8000/foo', fieldData, ...);
...then you'll have to make an adjustment for the brackets
rs <- getsRequest (rqParam "rows[]")
cs <- getsRequest (rqParam "cols[]")

CMS made simple, Ctlmodulemaker how to get the url of an image

hi I've made a simple module with CTLModuleMaker in CMS made simple, in the template I call the necessary items like this:
{assign var="item" value=$itemlist[0]}
{$item->name->Label()}: {$item->name}<br/>
{$item->image->Label()}: {$item->image}<br/>
{$item->image_text->Label()}: {$item->image_text}<br/>
{$item->image_desc->Label()}: {$item->image_desc}<br/>
{$item->img_thumb->Label()}: {$item->img_thumb}<br/>
{$item->catagory->Label()}: {$item->catagory}<br/>
as you can see i call an image with {$item->image} but when i try to do something like this {$item->url} it returns the url of the whole page I'm trying to get the url of the image not the whole page.
any suggestions what i can do??
In a news template, it calls
<img src="{$item->file_location}/{$item->image->value}" />
You can also use {debug} to see all the variables being passed to the template in a separate popup window. This is my get out of jail free card when I can't find a field name.

Resources