Database View - Change Request Approval - Approval Status RAG

mrswann
Kilo Guru

I have created the view which seems to be working OK

u_change_request_approvals

change_request as chg, sysapproval_approver as ar, where chg_sys_id = ar_sysapproval (against the ar table)

I have started building out the table view fields for each

as (this seems a common requirement from the community, as there are a few threads...) clearly I need to include additional information about the Change Request at the Approval User level so they can "sort Approvals by Scheduled Start" as the most obvious use case; if they need much more info they need to just access the change request but some aesthetics like short description, change type, requested by, are all nice to haves...

the issue is when I try this - the lovely coloured icon (RAG) next to the state is not showing as it would do under the main list of the approvals in the root table

Am I missing something? I can't find any other queries about this but it certainly feels a step back

I triedmoving the join to the chg table and making it a left join and seeing if that made a difference... no difference

1 ACCEPTED SOLUTION

Steve McCarty
Mega Guru

If I am reading your question correctly the colored icons are the field styles defined for the Approval tables.   Those styles only apply to the approval table, not your database view.   Your database view is treated as a new table in this case.   So to get those icons on your database view you have to define the field styles for your new "table" explicitly.   You should be able to find the style definitions for the change table and the recreate them for your database view.



-Steve


View solution in original post

13 REPLIES 13

With a UI Action assigned to the list context menu to update the current.state or current.ar_state I am getting security constraints prevention message.



I have added an ACL record to write to this field but still occurs.


You may have to change the UI action to get a GlideRecord object that points directly to the approval instead of the "current" database view object.   You should be able to change the state on the approval object and then update that from your script.  



-Steve


Sounds great - but I'm still struggling - I get the following error upon clicking the UI Action:


"Security does not allow the execution of that action against the specified record"



However it seems this error is being generated before it's trying to actually update anything; based on me including an Alert into the script which doesn't fire...



This is my current UI Action:



approveApprovalFromView();



function approveApprovalFromView() {


  var gr = new GlideRecord('sysapproval_approver');


  gr.addQuery('sys_id', current.ar_sys_id);


  gr.query();


  if (gr.next()) {


          // exists


alert('Test');


gr.state='approved';


   


  } else {


          gs.addErrorMessage("Something wrong with Approval. Please access the Approval Record directly to perform your updates.");


  }


current.update();


}



I have also tried including an execute record ACL against the view to no avail (guesswork :S )



The following javascript debug line:



19:53:26 (206)u_change_request_approvals_list.do[00:00:00.188] *** WARNING *** GlideAjax.getXMLWait - synchronous function - processor: AJAXActionSecurity


UI Actions are client scripts so you can't use the "current" object or the gs objects.   Those are only for server side scripts.   So line 5 should be gr.addQuery('sys_id', g_form.getValue('ar_sys_id'));   Also you want to update the gr object after you change the state, not the "current" object.   So delete line 15 and add gr.update(); on line 11.   Then change the gs.addErrorMessage() function call on line 13 to either an alert() or a g_form.addErrormessage().



-Steve


I am still getting the same error just to run an alert against the action with no other code, so even though the following code is probably valid (on basis it is client not server side) - I need to fix the permissions issue...





approveApprovalFromView();




function approveApprovalFromView() {


  var gr = new GlideRecord('sysapproval_approver');


  gr.addQuery('sys_id', g_form.getValue('ar_sys_id'));


  gr.query();


  if (gr.next()) {


          // exists


gr.state='approved';


gr.update();    


  } else {




          alert('Something wrong with Approval. Please access the Approval Record directly to perform your updates.');


       


  }




}



My ACL contains an execute operation on processor type for the view itself ; and I have tried doing this with this set to inactive to the same result.