Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.

Moderators: ArturoRobles, ArturoRobles

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
#791827
Hello,

Basically, I'm trying to figure out the best way to use links and navigate through steps. I decided to go with the RESTful way and will be doing something like so -
Code: Select all
var host = PMDynaform.getHostName();              // get hostname
var ws = PMDynaform.getWorkspaceName();           // get current workspace
var token = PMDynaform.getAccessToken();          // get access Token
var ProcessID = ('#ProcessID');                   // get process ID
var TaskID = ('#TaskID');                         // get task ID
 
function getSteps() {
    $.ajax({
      //get the steps
        url: host+"/api/1.0/"+ws+"/project/"+ProcessID+"/activity/"+TaskID+"/steps/",    
        data: {},                        
        type: "GET",                              
        beforeSend: function(xhr) {
            xhr.setRequestHeader('Authorization', 'Bearer '+token);
        }
		})
      .success(function(steps) {
        //grab all of the buttons
        var buttons = document.getElementsByClassName('button');
        for (var i = 0; i < steps.length; i++) {
          //loop over and add a click handler
            buttons[i].addEventListener('click', function() {
                window.location.href = 'cases_Step?TYPE=' + steps[i].step_type_obj + '&UID=' + steps[i].step_uid + '&POSITION=' + steps[i].step_position + '&ACTION=' + steps[i].step_mode;
            });
				}
			});
}    

The data will be coming from
Code: Select all
GET http://localhost/api/1.0/test/project/26312749458cd8450ecc8a0070198805/activity/33848747258cd8592a8b895038421902/steps
Code: Select all
 {
        "step_uid": "5112158735910961c37ca50036630979",
        "step_type_obj": "DYNAFORM",
        "step_uid_obj": "173740600590380904b7a98047114990",
        "step_condition": "",
        "step_position": 3,
        "step_mode": "EDIT",
        "obj_title": "Form Part 1",
        "obj_description": "test info",
        "triggers": []
      },

The code is not complete/working, but I am looking for tips on how I would add javascript links that will go through the steps. I won't be using processmaker links.
User avatar
By amosbatto
#791836
Your window.location.href will need to be the complete URL, not a relative URL. Something like this:
Code: Select all
window.location.href = 'http://example.com/sysworkflow/en/neoclassic/cases/cases_Step?TYPE=' + steps[i].step_type_obj + '&UID=' + steps[i].step_uid + '&POSITION=' + steps[i].step_position + '&ACTION=' + steps[i].step_mode;
The second problem is that you will be redirected to the login page, so the user will have to login once, before continuing. Your REST login won't work when calling a URL in the PM interface.
REST API Question

I am currently looking at developing a portlet for[…]

Everybody wants to be famous, but nobody wants to […]

Hi, I attached a sample config file, Please check […]

Error clicking on Participated

Hi, I attached a sample config file, Please check […]