Finding the shared project Name

Hello!,

I am using Ax2012.

I am trying to find a particular project name in shared project. But i am getting CLRObject object not initialized Error.

Anyleads would be appreciable.

I used this code so Far.

static void LearningProjectName(Args _args)
{
    ProjectNode      sharedProject = Infolog.projectRootNode().AOTfindChild("Shared");
    TreeNodeIterator   treeIterator;
    TreeNode        childNode;
    System.String searchString;
    
    searchString.Contains("1234");

    if(sharedProject)
    {
        treeIterator = sharedProject.AOTiterator();
        if(treeIterator)
        {
            childNode = treeIterator.next();
            while (childNode)
            {
                    searchString.CompareTo(childNode.AOTname());
                if(searchString)
                {
                    info(strFmt(' %1', childNode.AOTname()));
                    childNode = treeIterator.next();
                }
                else
                {
                    childNode = treeIterator.next();
                }
            }
        }
        sharedProject.treeNodeRelease();
    }
}

Thanks

Did you debug the code?what was the outcome?
Also try unchecking a checkbox with name :Execute business option cil and see if it makes any difference while you are troubleshooting the issue.
This checkbox is located on the path mentioned below:
Tools > Options > Development > General > Execute business operations in CIL

Regards
amit

You never set any value to searchString; that’s the key problem.
Also, why don’t you simply use a normal X++ str type and the comparison operator (=) instead of the .NET object System.String and its CompareTo() method?

Hello Martin,

Thanks for your reply!.

I cannot use ‘==’ operator as I am going to give only the partial string of the object name.
And also I have set the value for searchString ,‘1234’ is the value. I have created a project named “Test12345”. So i want this project name to displayed on the info .

Thanks.

Hello Amit!,

I tried Unchecking the checkbox u have mentioned still I am getting the same Error.
Thanks.

I referred to CompareTo, not Contains(). X++ naturally have a solution for that too: strContains().
Anyway, the key bug is that the string is always empty. Please fix this bug instead of playing with completely unrelated things such as CIL (jobs don’t run in CIL and it wouldn’t magically fix bugs in your code anyway).

Hello Martin,

I modified the code and used strContains() method and it is working fine. Thanks for your help and time.

Thanks.