Update Project state based on Project task State

rick48
Tera Contributor

Hello everyone 

I have a requirement whenever all associated project task is closed the project State should move to ''Pending-sign off'' 

The OOB functionality is whenever all associated project task is closed the project State moves to closed.

How can i change this accordingly to work for my requirement?

Any help would be appreciated. Thanks in advance.

6 REPLIES 6

MrMuhammad
Giga Sage

Hi,

Yes JWT is introduced as part of Madrid release. In order to have JWT available as an authentication type, you must first enable the plugin. That plugin is “Integration - Multiple Provider Single Sign-On Installer” with id com.snc.integration.sso.multi.ui . After that is activated, JWT will be an option for authentication and inside the X509 Certificates.

 

Please refer to below link to read through the details of hw JWT can be leveraged as part of your integration.

INTEGRATING SERVICENOW TO BOX WITH JWT

 

Please mark this accepted & helpful if it helps.

 

Thanks & Regards,

Sharjeel

Regards,
Muhammad

Akshata jamdar
Mega Guru

Hello rick,

 

Please check below block this might help you,

https://community.servicenow.com/community?id=community_article&sys_id=72aca625dbd0dbc01dcaf3231f961...

 

Kindly mark an answer as correct and helpful if it will resolve your query.

Regards,

Akshata

 

Tony DiRienzo
Giga Guru

That requirement is not practical, and you should suggest an alternative solution.  Projects and Project Tasks are both extensions of Planned Tasks in ServiceNow, and Planned Tasks have a complex state calculation engine which calculates the current state of a parent task based off of the state of all of its children.  The script libraries behind Planned Task state calculation are complex, and customizing them for something like this would mean taking on considerable technical debt. 

Based on ServiceNow's Planned Task state calculation engine, it is correct for a parent task to calculate to "Closed" when all of its children are in a closed state.  Why not work with the state calculation engine instead of fighting against it?  It would be much cleaner to add a "Sign-off" task to every Project that the PMs can close out once all of the other tasks are completed. 

I have worked with enough PMs in the past to guess that they will complain about this:  "I want to see the 'Pending sign-off' state in my Project report.  I don't want to have to click into each Project and check if all the other tasks are completed."  You can accomplish this as follows:

First, you will need to create a new state on the pm_project table called "Pending sign-off".  Then you will need to map it to the Work in Progress state bucket.  You can do this from the dictionary override for state on the pm_project table.  You can read more about how to do this on the documentation site: Customize a state for project or project task

Next, you should create a business rule on the Project table that creates a "Sign-off" task and adds it to the Project whenever a new Project is inserted.  You should come up with some way to easily identify this sign-off task later in a script (one idea might be to add a checkbox field to the Project Task table to track whether this task is a sign-off task).

Finally, add a business rule to the Project Task table.  When the state on a Project Task changes, use the PlannedTaskStateUtil script include to check if the new state is in the closed bucket:

var ptsu = new PlannedTaskStateUtil(current);
var stateBucket = ptsu.getBucketForState(current.state);
if (stateBucket == PlannedTaskStateUtil.CLOSE_STATES) {
    ...
}

If the Project Task has changed to a closed state, and if its parent is the Project, then you should do a GlideRecord query for all Project Tasks that are children of that Project and check each of their states.  If all of them are in a closed state except for the sign-off task (this is where you will need a method of identifying the sign-off task as I mentioned above), then update the Project's state to "Pending sign-off".  This will work, because in this scenario the Project's calculated state bucket is Work in Progress, and you have defined "Pending sign-off" as a Work in Progress state.

Now the Project will show as in "Pending sign-off" state in the PM's Project report.  The PM can simply complete the Sign-off task, and the Project state will switch to closed because all of the Project Tasks are closed.

Again, what I have suggested here works with the way the system is designed, and it is not likely to break or require review when you apply a future patch or version upgrade (it has low-to-no technical debt). Customizing the out-of-box scripts to do something other than what they were designed to do would be working against the system, and it is very likely that you would have to review and merge skips in future patches and version upgrades (it has moderate technical debt).

I hope this helps you.

Milind Gharte
Kilo Guru

Hi ,

Here is snap shot of BR that make changes .

find_real_file.png

 

Here are links which may help you.

https://community.servicenow.com/community?id=community_question&sys_id=0ed64ba5db1cdbc01dcaf3231f96...

 

https://community.servicenow.com/community?id=community_question&sys_id=ec355240dbfb9b00fff8a345ca96...

 

If it helps,Please mark Correct and 👍 Helpful.

Warm Regards,

Milind