public static string getAssignedSDSDocumentUrl( CswNbtResources _CswNbtResources, CswPrimaryKey MaterialId )
        {
            string url = "";
            if( _CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.SDS ) )
            {
                CswNbtMetaDataObjectClass SDSDocOC = _CswNbtResources.MetaData.getObjectClass( CswEnumNbtObjectClass.SDSDocumentClass );
                CswNbtMetaDataNodeType SDSDocumentNT = SDSDocOC.FirstNodeType;

                CswNbtView docView = getAssignedSDSDocumentsView( _CswNbtResources, MaterialId );

                // We need to re-add these properties because they were removed from the 'Assigned SDS' view in Case 31223
                CswNbtMetaDataNodeTypeProp LinkNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.Link );
                docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], LinkNTP );
                CswNbtMetaDataNodeTypeProp FileNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.File );
                docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], FileNTP );
                CswNbtMetaDataNodeTypeProp FileTypeNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( CswNbtPropertySetDocument.PropertyName.FileType );
                docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], FileTypeNTP );

                // If ChemWatch is enabled, we need to check for this type of file too
                if( _CswNbtResources.Modules.IsModuleEnabled( CswEnumNbtModuleName.ChemWatch ) )
                {
                    CswNbtMetaDataNodeTypeProp ChemWatchNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( PropertyName.ChemWatch );
                    docView.AddViewProperty( docView.Root.ChildRelationships[0].ChildRelationships[0], ChemWatchNTP );
                }

                CswNbtObjClassUser currentUserNode = _CswNbtResources.Nodes[_CswNbtResources.CurrentNbtUser.UserId];
                CswNbtObjClassJurisdiction userJurisdictionNode = _CswNbtResources.Nodes[currentUserNode.JurisdictionProperty.RelatedNodeId];

                ICswNbtTree docsTree = _CswNbtResources.Trees.getTreeFromView( docView, false, false, false );
                docsTree.goToNthChild( 0 ); //This is a property view, so the data is on the 2nd level
                int childCount = docsTree.getChildNodeCount();
                int lvlMatched = Int32.MinValue;
                string matchedFileType = "";
                CswNbtTreeNodeProp matchedFileProp = null;
                CswNbtTreeNodeProp matchedLinkProp = null;
                CswNbtTreeNodeProp matchedChemWatchProp = null;
                CswPrimaryKey matchedNodeId = null;

                if( childCount > 0 )
                {
                    for( int i = 0; i < childCount; i++ )
                    {
                        docsTree.goToNthChild( i );

                        string format = "";
                        string language = "";
                        string fileType = "";
                        CswNbtTreeNodeProp fileProp = null;
                        CswNbtTreeNodeProp linkProp = null;
                        CswNbtTreeNodeProp chemWatchProp = null;
                        CswPrimaryKey nodeId = docsTree.getNodeIdForCurrentPosition();

                        foreach( CswNbtTreeNodeProp prop in docsTree.getChildNodePropsOfNode() )
                        {
                            CswNbtMetaDataNodeTypeProp docNTP = _CswNbtResources.MetaData.getNodeTypeProp( prop.NodeTypePropId );
                            switch( docNTP.getObjectClassPropName() )
                            {
                                case PropertyName.Format:
                                    format = prop.Field1;
                                    break;
                                case PropertyName.Language:
                                    language = prop.Field1;
                                    break;
                                case PropertyName.FileType:
                                    fileType = prop.Field1;
                                    break;
                                case PropertyName.File:
                                    fileProp = prop;
                                    break;
                                case PropertyName.Link:
                                    linkProp = prop;
                                    break;
                                case PropertyName.ChemWatch:
                                    chemWatchProp = prop;
                                    break;
                            }
                        }

                        if( lvlMatched < 0 )
                        {
                            matchedFileType = fileType;
                            matchedFileProp = fileProp;
                            matchedLinkProp = linkProp;
                            matchedChemWatchProp = chemWatchProp;
                            matchedNodeId = nodeId;
                            lvlMatched = 0;
                        }
                        if( null != userJurisdictionNode )
                        {
                            if( lvlMatched < 1 && format.Equals( userJurisdictionNode.Format.Value ) )
                            {
                                matchedFileType = fileType;
                                matchedFileProp = fileProp;
                                matchedLinkProp = linkProp;
                                matchedChemWatchProp = chemWatchProp;
                                matchedNodeId = nodeId;
                                lvlMatched = 1;
                            }
                            if( lvlMatched < 2 && language.Equals( currentUserNode.Language ) )
                            {
                                matchedFileType = fileType;
                                matchedFileProp = fileProp;
                                matchedLinkProp = linkProp;
                                matchedChemWatchProp = chemWatchProp;
                                matchedNodeId = nodeId;
                                lvlMatched = 2;
                            }
                            if( lvlMatched < 3 && format.Equals( userJurisdictionNode.Format.Value ) && language.Equals( currentUserNode.Language ) )
                            {
                                matchedFileType = fileType;
                                matchedFileProp = fileProp;
                                matchedLinkProp = linkProp;
                                matchedChemWatchProp = chemWatchProp;
                                matchedNodeId = nodeId;
                                lvlMatched = 3;
                            }
                        }
                        docsTree.goToParentNode();
                    }
                    switch( matchedFileType )
                    {
                        case CswEnumDocumentFileTypes.File:
                            int jctnodepropid = CswConvert.ToInt32( matchedFileProp.JctNodePropId );
                            url = CswNbtNodePropBlob.getLink( jctnodepropid, matchedNodeId );
                            break;
                        case CswEnumDocumentFileTypes.Link:
                            CswNbtMetaDataNodeTypeProp linkNTP = SDSDocumentNT.getNodeTypePropByObjectClassProp( PropertyName.Link );
                            //url = CswNbtNodePropLink.GetFullURL( linkNTP.Attribute1, matchedLinkProp.Field1_Big, linkNTP.Attribute2 );
                            url = CswNbtNodePropLink.GetFullURL( linkNTP.DesignNode.getAttributeValueByColumn( CswEnumNbtPropertyAttributeColumn.Attribute1 ),
                                                                 matchedLinkProp.Field1_Big,
                                                                 linkNTP.DesignNode.getAttributeValueByColumn( CswEnumNbtPropertyAttributeColumn.Attribute2 ) );
                            break;
                        case CswEnumDocumentFileTypes.ChemWatch:
                            url = "Services/ChemWatch/GetSDSDocument?filename=" + matchedChemWatchProp.Field1;
                            break;
                    }
                }
            }
            return url;
        }