This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - Error Promomt when Click on custom method to create a project

AbhishekSrivastava - Tuesday, May 24, 2016 1:52 AM:

Hello friends,

I am try to create a project from other item type name "TestItem" by creating a custom method name "Create a Project" on Action menu So when i click then it prompts error   

" error=TypeError: srcNode is null"

Method as shown  below

try{
var inn=this.newInnovator();
var TestItem=this.newItem("TestItem","get");
TestItem.setAttribute("select","id","project_name");
TestItem.setID(this.getID());
var TestItems=TestItem.apply();
if(TestItems.isError())
{
top.aras.AlertError("Error:"+TestItems.getErrorDetail());
}
var Project=top.aras.newItem("Project","add");
top.aras.setItemProperty(Project,"name",this.getProperty("project_name"))
top.aras.uiShowItemEx(Project,"tab view",true);
}
catch(e)
{
top.aras.AlertError("error="+e);

}

So if anybody have a solution on above query so please help.

 

Thanks in advance

Abhishek Srivastava



Yoann Maingon - Saturday, June 11, 2016 11:45 AM:

1) why do you query your TestItem which I believe is already your context??

2) this TestItem.setAttribute("select","id","project_name"); shoudl be TestItem.setAttribute("select","id,project_name");

3) you create an Item but you don't execute it's creation using the item.apply() method

This may work


var Project=top.aras.newItem("Project","add");

Project.setProperty("name",this.getProperty("project_name"))

Project = Project.apply();

top.aras.uiShowItemEx(Project.getItemByIndex(0).node,"tab view",true);