Jump to content
lawrencem

Fuction needs to return to home page after being invoked

Recommended Posts

lawrencem    1

Hoping for your help all.

I have created a function that is invoked by a couple of approval buttons on my detail.cr page.

The function is as follows

{

var url=cfgCgi+

"?SID="+cfgSID+

"+FID="+fid_generator()+

"+FACTORY="+factory+

"+PERSID="+persid+

"+OP=UPDATE"+

"+ACTIVITY_LOG_TYPE="+type+

"+HTMPL=detail_alg_edit.htmpl" +

"+AUTO_OVERRIDE_LOCK=true";

display_new_page(url);

}

 

The problem I have is after invoking the 'detail_alg_edit.htmpl', changing the status (as desired) and clicking 'Save' I want the save action to drop me back to the Service Desk home page, any ideas how this can be coded. I need to do this as I am opening service desk via an email link - http://MYSDSERVER:80/CAisd/pdmweb.exeOP=SEARCH+FACTORY=cr+SKIPLIST=1+QBE.EQ.id=1234567; and when doing the normal 'Save' submit, my page just hangs on a loading screen, it seems that Service Desk doesn't know where to direct me.

Share this post


Link to post
Share on other sites
cdtj    22

Hi,

as I remember 2 variables are used to define post-submit action:

- hidden input named HTMPL;

- javascript variable ahdframeset.top_splash.next_persid;

Befor clicking save button use browser's console to check their values, try to pass show_main_detail.htmpl as value of HTMPL, and empty value for next_persid.

Regards, cdtj

Share this post


Link to post
Share on other sites
lawrencem    1

 

16 hours ago, cdtj said:

Hi,

as I remember 2 variables are used to define post-submit action:

- hidden input named HTMPL;

- javascript variable ahdframeset.top_splash.next_persid;

Befor clicking save button use browser's console to check their values, try to pass show_main_detail.htmpl as value of HTMPL, and empty value for next_persid.

Regards, cdtj

Good day;

Its a real honour to have a post from yourself cdtj; I have seen a LOT of your posts in the past and how much you have helped people and for that I am really quite humbled.

Forgive me ignorance please, but I am really new to functions (having never needed to use them in customisations before), could you please advise me roughly where these variables should sit within the page; (I take it they need to be on the detail.cr; rather than the detail_alg page?)

Also should I be substituting display_new_page(url); in favour of ahdframeset.top_splash.next_persid or add this as an addition within the function?

Your help once more would be greatly appreciated.

Share this post


Link to post
Share on other sites
cdtj    22

so much fame :) but currently i'm out of business and haven't hope to find another job related to ca sdm.

Yeah, seems like everything is much easier, have you tried to call:

popupActivityWithURL(url);

instead of display_new_page?

Share this post


Link to post
Share on other sites
lawrencem    1

Now im getting somewhere :) - thankyou

so 'popupActivityWithURL(url)'; is now returning me into the body of the ticket (even if I've opened it from an email link - so an improvement to a broken link on a page...) however; this has now created another problem.. as the ticket window I return to is the original and does not refresh - so the status change that has just occurred, is not apparent. (This status change is being called via a linked event notification association with a 1 second delay)

Is there a way to either...

1) Force an auto refresh on the ticket page once the popup window disappears? (This is on a 12.6 installation by the way) which would be the best solution.

or alternatively

2) Drop the user back to the home page URL?

Once again really appreciate your help. I am shocked that you are unable to find work in this field. Sadly I think a lot of companies are moving over to Jira these days which I really do not like as a Service Desk solution.

Edited by lawrencem

Share this post


Link to post
Share on other sites
cdtj    22

found it!

popupActivityWithURL(url, "status");

second argument affects on variable: _dtl.tabReloadOnSave which is used to notify system when you want to refresh entire page on publish and when you dont.

  • Like 1

Share this post


Link to post
Share on other sites
lawrencem    1

YES!!!

IT WORKS!!! You sir, are a legend! :D

One day, I hope we cross paths, as I owe you a pint (or chilled beverage of preference!)

 

  • Like 1

Share this post


Link to post
Share on other sites
cdtj    22

which country should I visit? :D

Share this post


Link to post
Share on other sites
lawrencem    1

United Kingdom is where I am based. In sleepy Somerset, (cider country).

 

Share this post


Link to post
Share on other sites
lawrencem    1

If you could be so kind as to allow me to trouble you again?

Whilst this is working perfectly for my analyst interface is there any reason that you know of why my popup window fails to close / refresh status when I invoke the same function from the employee interface?

Edited by lawrencem

Share this post


Link to post
Share on other sites
cdtj    22

As I remember employees are not allowed to use popups.

You can try to use it with your previous method - display_new_page.

I checked employee interface files and found function defined in this way:

function zCallActivity(aty) {
	var query_str = cfgCgi +
		"?SID=" + cfgSID +
		"+FID=" + fid_generator() +
		"+FACTORY=cr" +
		"+PERSID=$args.persistent_id" +
		"+OP=UPDATE" +
		"+AUTO_OVERRIDE_LOCK=true" +
		"+EDIT_HTMPL=request_status_change.htmpl" +
		"+ACTIVITY_LOG_TYPE=" + aty;
	<PDM_IF "1" == "${args.KEEP.IsPopUp:0}">
		query_str += "+KEEP.IsPopUp=1";
	</PDM_IF>
	document.location.href = query_str;
}

 

Share this post


Link to post
Share on other sites
lawrencem    1
17 hours ago, cdtj said:

As I remember employees are not allowed to use popups.

You can try to use it with your previous method - display_new_page.

I checked employee interface files and found function defined in this way:


function zCallActivity(aty) {
	var query_str = cfgCgi +
		"?SID=" + cfgSID +
		"+FID=" + fid_generator() +
		"+FACTORY=cr" +
		"+PERSID=$args.persistent_id" +
		"+OP=UPDATE" +
		"+AUTO_OVERRIDE_LOCK=true" +
		"+EDIT_HTMPL=request_status_change.htmpl" +
		"+ACTIVITY_LOG_TYPE=" + aty;
	<PDM_IF "1" == "${args.KEEP.IsPopUp:0}">
		query_str += "+KEEP.IsPopUp=1";
	</PDM_IF>
	document.location.href = query_str;
}

 

Hi and thanks again for yet another response cdtj :) you're really making my week

So I have tried out a few more employee functions, including using

display_new_page(url, "Status" );

I have also tired using popup method (as per my working Analyst interface;) as previously mentioned, I do not have any such pdm_if restriction on my employee function file, (it is coded the same way as my analyst one)

But I am still not getting the desired result of a page refresh to display that status change.

Is there any other known way to achieve this?

Share this post


Link to post
Share on other sites
cdtj    22

hi, so much stress talking to a native speaker D:

may you confirm your situation?

on employee interface if you're using popup method - main page doesn't refresh, if you're displaying new form on the same page, it being stuck?

so, you're using same page for employee and analyst role?

Share this post


Link to post
Share on other sites
lawrencem    1

Hi sorry, reading that back it wasn't very clear at all was it :(  and sorry if I am causing you stress.

I am using on my employee form the following function

{

var url=cfgCgi+

"?SID="+cfgSID+

"+FID="+fid_generator()+

"+FACTORY="+factory+

"+PERSID="+persid+

"+OP=UPDATE"+

"+ACTIVITY_LOG_TYPE="+type+

"+HTMPL=detail_alg_edit.htmpl" +

"+AUTO_OVERRIDE_LOCK=true";

display_new_page(url, "Status" );

}

 

 (I have also tried  popupActivityWithURL(url, "status" ); on the bottom line.

 

Both solutions however, are not refreshing the employee page automatically - as in, the status change doesn't show (even though it has happened successfully). On my analyst view I get the expected result - the refresh is happening as desired.

Edited by lawrencem

Share this post


Link to post
Share on other sites
cdtj    22

but display_new_page should open new form in the same page (ahdframe) and after submitting should return you back isn't it?

Could you try this one:

{
	var url=cfgCgi+
	"?SID="+cfgSID+
	"+FID="+fid_generator()+
	"+FACTORY="+factory+
	"+PERSID="+persid+
	"+OP=UPDATE"+
	"+ACTIVITY_LOG_TYPE="+type+
	"+EDIT_HTMPL=detail_alg_edit.htmpl" +
	"+AUTO_OVERRIDE_LOCK=true";
	display_new_page(url);
}

Share this post


Link to post
Share on other sites
lawrencem    1
24 minutes ago, cdtj said:

but display_new_page should open new form in the same page (ahdframe) and after submitting should return you back isn't it?

Could you try this one:


{
	var url=cfgCgi+
	"?SID="+cfgSID+
	"+FID="+fid_generator()+
	"+FACTORY="+factory+
	"+PERSID="+persid+
	"+OP=UPDATE"+
	"+ACTIVITY_LOG_TYPE="+type+
	"+EDIT_HTMPL=detail_alg_edit.htmpl" +
	"+AUTO_OVERRIDE_LOCK=true";
	display_new_page(url);
}

Yes, this does drop me back to the detail.cr page after the status update is saved (both from an email link and via Service Desk) but the status field, still doesn't show the update that has just occurred, unless I refresh the screen again (manually).

Much appreciate all of your help thus far.

Share this post


Link to post
Share on other sites
cdtj    22

this sounds very strange, could you share your detail_alg.htmpl for employee form group?

Share this post


Link to post
Share on other sites
lawrencem    1
On ‎16‎/‎07‎/‎2017 at 9:33 AM, cdtj said:

this sounds very strange, could you share your detail_alg.htmpl for employee form group?

Thanks for your continued perseverance :) I have attached my file

 

detail_alg.htmpl

Share this post


Link to post
Share on other sites
cdtj    22
19 hours ago, lawrencem said:

Thanks for your continued perseverance :) I have attached my file

 

detail_alg.htmpl

Hi, do you use spel code to apply changes? because I didn't find any inputs for status or other attrs in attached file.

Anyway, I remembered a universal solution, which will navigate employee to initial form and will show update message.

Here is a way how to achieve it:

1. Add variable to func:

{
var url=cfgCgi+
	"?SID="+cfgSID+
	"+FID="+fid_generator()+
	"+FACTORY="+factory+
	"+PERSID="+persid+
	"+OP=UPDATE"+
	"+ACTIVITY_LOG_TYPE="+type+
	"+EDIT_HTMPL=detail_alg_edit.htmpl" +
	"+AUTO_OVERRIDE_LOCK=true" +
	"+KEEP.zBackHome=1";
	display_new_page(url);
}

2. Use variable in condition on detail_alg.htmpl, add this code where hidden inputs are located:

<PDM_IF "$args.KEEP.zBackHome" == "1">
<INPUT TYPE=hidden NAME=HTMPL VALUE="home.htmpl">
<INPUT TYPE=hidden NAME=KEEP.HOME_ACTION VALUE="Z_SUCCESS">
</PDM_IF>

3. Variable HOME_ACTION within KEEP array will be passed to home.htpml, so you can display custom message depending on it, find PDM_LINK OP=SHOW_DETAIL on home.htmpl and update it in this way:

<PDM_LINK OP="SHOW_DETAIL" PERSID="$args.persistent_id" onmouseover="window.status = "Open Issue ${args.ref_num}"; return true;" onmouseout="window.status = window.defaultStatus; return true;">
	<PDM_IF "$args.KEEP.HOME_ACTION" == "Z_SUCCESS">
		<span class="alertmsg portlet_body_text">Issue ${args.ref_num} was updated.</span>
	<PDM_ELSE>
		<span class="alertmsg portlet_body_text">Issue ${args.ref_num} was created.</span>
	</PDM_IF>
</PDM_LINK>

 

  • Like 1

Share this post


Link to post
Share on other sites
lawrencem    1

Thank you cdtj

I will test this further in the morning, alas I have run out of time today.

I am hitting a few snags as I have a customised 'home.htmpl' page, so I am trying to debug where this is failing.

I will update with my findings in the morning.

 

Edited by lawrencem

Share this post


Link to post
Share on other sites
lawrencem    1

Hi again,

So I have had a week working on other things; back on this today I have retested the code, again this morning, but even with the above 3 statements added to the pages in the correct positions I am still not getting the desired page refresh action on my employee form.

Happy to share files if this helps trouble-shoot things, but I can't help but feel I must be missing something here. I can't understand why my analyst form works, yet my employee one does not :(

As always I appreciate the support

Share this post


Link to post
Share on other sites
cdtj    22

hi,

one question to determine starting point: what happens when employee clicks Save button?

Regards, cdtj

Share this post


Link to post
Share on other sites
lawrencem    1
15 hours ago, cdtj said:

hi,

one question to determine starting point: what happens when employee clicks Save button?

Regards, cdtj

Good morning;

So, let me start from the beginning. The user opens up the request via an email link; and is presented with 3 buttons;

Approve; Partially Approve and Reject, - all are linked to the (above) function. The code behind each of the 3 buttons is

         

                 ImgBtnCreate("btnzup", "APPROVE ALL", "z_customer_chase('$args.persistent_id', 'cr','BUS_APP')", "defer", 0)

                 ImgBtnCreate("btnzup1", "APPROVE PARTIALLY", "z_customer_chase('$args.persistent_id', 'cr','BUS_PAPP')", "defer", 0)

                 ImgBtnCreate("btnzup2", "REJECT", "z_customer_chase('$args.persistent_id', 'cr','BUS_REJ')", "defer", 0)

 

Each of these buttons requires a comment from the end user, so when one of these buttons in clicked a new window pops-up stating 'Update Required On Request 123456'. The user is required to enter a comment and click Save. When save is clicked the employee is returned back to the request screen; (not home.htmpl). This wouldn't be an issue, except that on the request screen, the status does not show the latest status change - the status remains the same. The only way the employee has of knowing there action was successful, is to scroll down to the activity log; where the latest activity has been written.

If the employee returns to the home page, and then goes back into the request, the status change has occurred.

I hope this helps.

Edited by lawrencem

Share this post


Link to post
Share on other sites
cdtj    22

Defaulty all new forms for employee interface group opens in a same window, have you tried to avoid popups? this could be a clue. Providing final code for z_customer_chase also might be helpful.

Share this post


Link to post
Share on other sites
lawrencem    1
34 minutes ago, cdtj said:

Defaulty all new forms for employee interface group opens in a same window, have you tried to avoid popups? this could be a clue. Providing final code for z_customer_chase also might be helpful.

Thanks once again for the reply;

Ok, I have supressed pop-ups and now have it all the frames loading in the same window, however my problem is still present.

The code for z_customer_chase is the function I have provided all along from the start  - but Alas, this is an error on my part, as I did not include the header line of my function I see...

         function z_customer_chase(persid,factory,type)

                  {

                        var url=cfgCgi+

                        "?SID="+cfgSID+

                        "+FID="+fid_generator()+

                              ect...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Announcements

    • Gregg

      Looking for the wiki content?

      12/20/2015

      Until I can transfer the wiki content over to the new Articles, you can find the old content here: http://www.greggsmith.net/wiki.
    • Gregg

      New site logo

      01/06/2016

      A special thanks to brianshs for creating a new site logo!
×