- 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-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-29-2015 07:44 AM
Absolute STAR!!! Works a treat.. thank you so much 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-09-2015 11:20 AM
any work around for scoped applications ?
I am getting below error.
Access to getXMLWait is not available in scoped applications.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-06-2015 04:04 AM
Could you send your script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2016 01:25 AM
Hi Harish,
I used the same script and Script Include. The problem is:
When i select the checkbox and it is populating the message. That is fine. When i selected one project from the related list then checkbox becomes unchecked. I am able to save. But when i again open the change form and it is already unchecked. When i check it again and try to save it again gives me message to add one project record in related list however one record is already added.
Please help.
Thanks in Advance.
Regards,
Punit