Redirection using client side script

89 views
Skip to first unread message

Arun Emmanuel

unread,
Nov 26, 2012, 8:39:05 AM11/26/12
to erpnext-dev...@googlegroups.com
Hi

How can i redirect into some pages based on some conditions?
Is there something like "window.location" in Js available so that i can redirect to some other pages based on certain conditions

Thanks

Rushabh Mehta

unread,
Nov 27, 2012, 12:04:00 AM11/27/12
to erpnext-dev...@googlegroups.com
Yes there is window.location in js.

In wnframework you can also use wn.route(page_name) to open a "virtual" Page.

best,
Rushabh




--
You received this message because you are subscribed to the Google Groups "ERPNext Developer Forum" group.
To post to this group, send email to erpnext-dev...@googlegroups.com.
To unsubscribe from this group, send email to erpnext-developer...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/erpnext-developer-forum/-/FnlRMhi9t0wJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 



--



Twitter: @rushabh_mehta

Arun Emmanuel

unread,
Nov 27, 2012, 12:15:47 AM11/27/12
to erpnext-dev...@googlegroups.com
Thanks Rushabh for your help. Its working fine now

I have one more doubt. Is there any way to restrict the access based on some user names??
Now we can restrict the access based on their user roles.
For ex i have 2 managers  .Both have the role Manager. But what i want to implement is that they can access docs in which they are part
ie while creating the data there is a field called manager . So only those manager can access that record where user name matches with the manager name.

Rushabh Mehta

unread,
Nov 27, 2012, 12:26:32 AM11/27/12
to erpnext-dev...@googlegroups.com
Arun,

You have to set "match" permissions in the Permission Manager - The field must be a Link field though.

best,
Rushabh

Arun Emmanuel

unread,
Nov 27, 2012, 12:31:58 AM11/27/12
to erpnext-dev...@googlegroups.com
Ok .. Thanks Rushabh.. I will try and let u know if i need any help

Thanks a lot

Arun Emmanuel

unread,
Nov 27, 2012, 1:04:18 AM11/27/12
to erpnext-dev...@googlegroups.com
HI Rushabh

Is there any option to stop loading a particular doctype from cache.. ie whenever i request for a particular doctype it should be loaded from cache.. And it should execute cur_frm.cscript.onload??

Thanks 
Arun

Arun Emmanuel

unread,
Nov 27, 2012, 1:04:50 AM11/27/12
to erpnext-dev...@googlegroups.com
On Tue, Nov 27, 2012 at 11:34 AM, Arun Emmanuel <arune...@gmail.com> wrote:
HI Rushabh

Is there any option to stop loading a particular doctype from cache.. ie whenever i request for a particular doctype it should not be loaded from cache.. And it should execute cur_frm.cscript.onload??

Rushabh Mehta

unread,
Nov 27, 2012, 1:16:49 AM11/27/12
to erpnext-dev...@googlegroups.com
Arun, why would you want to do this?

Sent from mobile

Arun Emmanuel

unread,
Nov 27, 2012, 1:20:42 AM11/27/12
to erpnext-dev...@googlegroups.com
HI rushabh

What i am planning to do is every time i load a particular doctype i ll call the onload function and check whether the logged in user can access the data or not. If he is restricted i have to redirect it to some other pages.
If i load the page for the first time this logic will work.. But from the second time onward its not calling the onload function

Thanks
Arun

Rushabh Mehta

unread,
Nov 27, 2012, 1:22:07 AM11/27/12
to erpnext-dev...@googlegroups.com
Use the cur_frm.cscript.refresh function - it is called every time a form is shown.

On Tue, Nov 27, 2012 at 11:50 AM, Arun Emmanuel <arune...@gmail.com> wrote:
time i load a particular doctype i ll call the onload function and check whether the logged in user can access the data or not. If he is restricted i have to redirect it to some other pages.
If i load the page for the first time this logic will work.. But from



Arun Emmanuel

unread,
Nov 27, 2012, 1:26:49 AM11/27/12
to erpnext-dev...@googlegroups.com
Thanks a lot Rushabh.. It works as per my requirement

Sorry .. I am new to your framework , tats why lots of doubt.But so excited  to start develop app using your wnframework
Thanks for your help and excepting your cooperation in future

Thanks 
Arun

Rushabh Mehta

unread,
Nov 27, 2012, 1:31:13 AM11/27/12
to erpnext-dev...@googlegroups.com
Cool - happy to help you.

Please feel free to update the wiki documentation in GitHub.

Also will be really nice if you can also document your process on a blog or something :)

best,
Rushabh

Arun Emmanuel

unread,
Nov 27, 2012, 1:33:22 AM11/27/12
to erpnext-dev...@googlegroups.com
Sure..

Arun Emmanuel

unread,
Nov 27, 2012, 2:01:16 AM11/27/12
to erpnext-dev...@googlegroups.com
Hi Rushabh

Is there any function to close the window using java script.. Something similar to window.close()??

Thanks 
Arun

Arun Emmanuel

unread,
Nov 27, 2012, 2:03:27 AM11/27/12
to erpnext-dev...@googlegroups.com
Or any function to stop loading the page??

Thanks

Anand Doshi

unread,
Nov 27, 2012, 2:08:31 AM11/27/12
to erpnext-dev...@googlegroups.com
Hi Arun,

What exactly are you trying to do? Please explain the scenario.

window.close will close the browser's tab.

Close button in erpnext's forms/pages just calls window.history.back

Thanks,
Anand.

Arun Emmanuel

unread,
Nov 27, 2012, 2:14:53 AM11/27/12
to erpnext-dev...@googlegroups.com
Thanks Anand

I think window.history.back will satisfy my requirement

Thanks 
Reply all
Reply to author
Forward
0 new messages