- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2015 04:37 AM
Hi,
We have a simple ttue/false field in our change form - u_relate_to_project - default is false
On submit, If this field is true, I need to check to make sure that there is at least one entry in the project>parent related list (which we also display on the change form related lists), if not then the user will get a notice to say they have to complete the project details.
Any suggestions please?
thanks
We are using Dublin Patch 7 and Project Management v3
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2015 07:25 AM
Hi LG,
Here is the code.
Onsubmit script
________________
function onSubmit() {
var istrue = g_form.getValue('u_relate_to_project');
if(istrue == 'true')
{
var curSysid = g_form.getUniqueValue();
var ga = new GlideAjax('check_projects_exists');
ga.addParam('sysparm_name','isProjectExist');
ga.addParam('sysparm_currentsysid', curSysid);
ga.getXMLWait();
var answer = ga.getAnswer();
if(answer == 'Not Exist')
{
alert('Please select one project');
return false;
}
}
}
__________________________________
Includescript
Name : check_projects_exists
Active : true
Client callable : true
Script:
var check_projects_exists = Class.create();
check_projects_exists.prototype = Object.extendsObject(AbstractAjaxProcessor,
{
isProjectExist: function()
{
var answer ='';
var cursysid = this.getParameter('sysparm_currentsysid');
gs.log('cursysid :'+cursysid);
var gr = new GlideRecord('task');
gr.addQuery('parent', cursysid);
gr.query();
if(!gr.next())
{
answer = "Not Exist";
}
else
{
answer = "Exist";
}
return answer;
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2015 04:45 AM
Write a on Submit client script to query for the related list table to see if any entries are present related to the change.
If no entries exist, alert user and stop the form from saving by using "return false;"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2015 05:52 AM
thanks.. it's actually the script bit i'm struggling with, sorry.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-27-2015 06:26 AM
If you can share the related list name and script you are working, i can be of further assistance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2015 06:14 AM
Thanks (sorry for the delay)
the related list is the project>parent list - where the change is the parent (Links to pm_project.parent)