Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By Throwaway
#813216
I have it set up using a back button with the attached code. The js works fine on the main process, but once we go into a sub-process and use a back-button, it just brings up a "submit" button and it freezes once you click it. So you have to restart the case.
Code: Select all
$(document).delegate("#btn_back", "click", function (e) {
	if (typeof localStorage["flagBackButton"] === "undefined" || localStorage["flagBackButton"] === "FALSE") {
		showSpinner();
		localStorage["flagBackButton"] = 'OK';
		appUid = app_uid;
		access_token = localStorage['pmAccessToken'];
		server = localStorage["restServer"];
		workspace = localStorage["workSpace"];
		$.ajax({
			type: 'POST',
			url: server + '/api/1.0/' + workspace + '/plugin-psLeadRegistrationPlugin/back-button',
			data: { APP_UID: appUid },
			beforeSend: function (xhr) {
				xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				xhr.setRequestHeader("Authorization", "Bearer " + access_token);
			},
			success: function (e) {
				spinner.stop(spinner_div);
				pmRestRequest('GET', '/api/1.0/' + workSpace + '/cases/' + app_uid + '/variables', false, null, getCase);
			},
			error: function (e) {
				console.log(e);
			}
		})
	} else {
		alert('Error: You can only go one task backwards!');
		$("#btn_back").attr("disabled", "disabled");
		localStorage["flagBackButton"] = "BLOCKED";
	}
	e.preventDefault();
});
By Throwaway
#813237
amosbatto wrote:When you are in a subprocess case, the Case UID and delegation index are different from the master case. Where are you getting your app_uid variable from?
Code: Select all
// reset current page to 1 for grids & pagination
	showSpinner();
	currPage = 1;
	if (form.app_uid) {
		app_uid = form.app_uid;
	}
This is where the app_uid is being grabbed from, so I guess it might be trying to use the first process id instead of the subprocess.
User avatar
By amosbatto
#813249
If you are getting the app_uid from the Dynaform properties, then it should be the correct case ID for the subprocess case, but check it to make sure.

Are you sure that your POST parameters are working?
If your custom REST endpoint can't read the APP_UID, then try this:
Code: Select all
         data: JSON.stringify({ APP_UID: appUid }),
         beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "Bearer " + access_token);
         }, 
By Throwaway
#813264
amosbatto wrote:If you are getting the app_uid from the Dynaform properties, then it should be the correct case ID for the subprocess case, but check it to make sure.

Are you sure that your POST parameters are working?
If your custom REST endpoint can't read the APP_UID, then try this:
Code: Select all
         data: JSON.stringify({ APP_UID: appUid }),
         beforeSend: function (xhr) {
            xhr.setRequestHeader("Authorization", "Bearer " + access_token);
         },

Should this go in the same location as where we are currently grabbing the app_uid or would it go somewhere in the process?
User avatar
By amosbatto
#813268
This is replacing the jQuery code that you posted, which I assume you are used in a DynaForm in the subprocess case.

You have to look at the code in plugin-psLeadRegistrationPlugin/back-button.php to determine if it expects a JSON string or not. If it expects JSON, then try using this jQuery code:
Code: Select all
     $.ajax({
         type: 'POST',
         url: server + '/api/1.0/' + workspace + '/plugin-psLeadRegistrationPlugin/back-button',
         data: JSON.stringify({ APP_UID: appUid }),
         beforeSend: function (xhr) {
            //xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); //probably not necessary if using JSON
            xhr.setRequestHeader("Authorization", "Bearer " + access_token);
         },
         success: function (e) {
            spinner.stop(spinner_div);
            pmRestRequest('GET', '/api/1.0/' + workSpace + '/cases/' + app_uid + '/variables', false, null, getCase);
         },
         error: function (e) {
            console.log(e);
         }
      })
By oaghwotu
#828101
Hello there. My app_uid returns null or empty. I have tried these two methods to return the app_uid, to no avail.
Code: Select all
const app_uid = PMDynaform.getProjectKeys().caseUID; 
const app_uid = frames.app_uid ? frames.app_uid : ''; 
Really appreciate your help.

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]

A Bet365 Clone Script is essentially a ready-made […]