how to restrict by creating new project task on the project forn when the state filed value changes to published or retired ?

hemachandra2
Tera Contributor

Hi All,

I have requirement that , how to restrict by creating new project task on the project forn when the state filed value changes to published or retired ?, we have new state filed on the form , if the value changes to "published or retired" then in ,  project task under related list, need to restrict creating new tasks?

Please help to achieve 

Thanks

Hemachandra

8 REPLIES 8

shloke04
Kilo Patron

Hi,

Write a Create operation table level ACL on Project Task table and then configure it as shown below:

find_real_file.png

So you can give your Field condition above and restrict it say give Roles as Admins in ACL above.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Shloke , 

Thanks for the response

ya basically ,we don't want to restrict all the times, only when we creating project in my custom view then only we have to restrict creation of project task, if the project is created in defalut view , so then no need to restrict and the the state field is on the project table and project task is different table

Thanks 

Hemachandra

Hi,

There can be other ways to handle this, what I can think of and works for me is listed below:

1) please create a new hidden field on your Project Table say name it as "View". This is required to capture the view which is getting loaded on Parent Project form and is needed to validate the child Related List.

find_real_file.png

2) Now once this field is created, create a UI Policy and hide this field so that it is not visible to users.

3) Now Please write a Display Business Rule and use the script below to capture the View name:

(function executeRule(current, previous /*null when async*/ ) {

    // Add your code here
    var view_name = '';
    if (gs.getSession().isInteractive()) {
        var map = gs.action.getGlideURI().getMap();
        if (map.get('sysparm_view') != null) {
            view_name = map.get('sysparm_view').toString();
			g_scratchpad.VIEWNAME = view_name;
        }
    }



})(current, previous);

find_real_file.png

find_real_file.png

Now write an On Load Client Script on Project table  i.e. View Name and use the script below to set your View Name:

function onLoad() {
    //Type appropriate comment here, and begin script below
    g_form.setValue('u_view_name', g_scratchpad.VIEWNAME);

}

find_real_file.png

Now once this is done, Right click on the header of Project Task Related List and then select Configure--> List Control as shown below:

find_real_file.png

Now use the script below in the field "Omit New Condition" as shown below. If this field is not present then add it to the Form layout and then use the same script as shared below:

if(parent.u_view_name == 'planning_console'){ // Replace "planning_console" with your custom View Name
	answer = true;
}else{
	answer = false;
}

find_real_file.png

Output:

find_real_file.png

This works for me in my PDI.

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

Hi Sholke,

Thanks for the code,

ya based on the view, its fine, but i have one more condition that , on the project form i have a custom filed that project state, when ever that filed moved to published then i don't want that new button for project task?, so when should i add that condition in the script?

Thanks

Hemachandra