Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
THRUST SERVICES & TOOLS
CLOUD EDITIONS
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
NewProfileDlg throws: System.Runtime.InteropServices.UCOMIConnectionPoin t.Advise
shirinp
I have created a Custom Command, and within this command, I am using IMANEXTLib.NewProfileDlg. When I add an event handler to this, I keep getting an Exception thrown :
System.Runtime.InteropServices.UCOMIConnectionPoint.Advise(Object pUnkSink, Int32& pdwCookie)
I believe this has something to do with the sinking, but I'm not sure how to resolve this. Has anyone experienced this? I would appreciate your help!!!
Below is a sample of my code:
IMANEXTLib._INewProfileDlgEvents_OnOKEventHandler del_OnOk;
//this extends IMANEXTLib.NewProfileDlgClass
MyPropertiesDlg pPropDlg = new MyPropertiesDlg();
del_OnOk = new IMANEXTLib._INewProfileDlgEvents_OnOKEventHandler( pPropDlg.OnOk );
//the exception is thrown here
pPropDlg.OnOK += new IMANEXTLib._INewProfileDlgEvents_OnOKEventHandler( pPropDlg.OnOk );
Find more posts tagged with
Comments
jny
Try this:
// Create an instance of the ImportCmd Object
ImportCmd cmd = new ImportCmdClass();
NewProfileDlg dlg = null;
IMANEXTLib._ICommandEvents_OnInitDialogEventHandler del_OnInit;
IMANEXTLib._INewProfileDlgEvents_OnChangeEventHandler del_OnChange;
// Wrapper handler to the ImportCmd_OnInitDialog event handler
private void OnInitDialog (object dialog)
{
// Get handle to the dialog object
dlg = (NewProfileDlg)dialog;
// Add an event handler for the NewProfileDlg_OnChange Event.
del_OnChange = new _INewProfileDlgEvents_OnChangeEventHandler(OnChange);
dlg.OnChange +=new _INewProfileDlgEvents_OnChangeEventHandler(OnChange);
}
// Wrapper handler to the NewProfileDlg_OnChange event handler
private void OnChange (object obj, AttributeID field)
{
// TODO: You may perform your task by the field that is entered.
if (field == AttributeID.nrDatabase)
dlg.SetAttributeValueByID(field, "DSS2", true);
//MessageBox.Show( "Here, you can perform any tasks you'd like when " + "Custom1 field is visited.");
}
private void Form1_Load(object sender, System.EventArgs e)
{
IManDMS dms = new ManDMSClass();
IManSession sess = dms.Sessions.Add("NTDEVSUPPORT");
sess.TrustedLogin();
string path =
@C:\Temp\Dummy Docs\testfil.doc
;
//Add an event handler for the OnInit Event of the ImportCmd object.
del_OnInit = new IMANEXTLib._ICommandEvents_OnInitDialogEventHandler (OnInitDialog);
cmd.OnInitDialog +=new _ICommandEvents_OnInitDialogEventHandler(OnInitDialog);
ContextItems context = new ContextItemsClass();
context.Add("DestinationObject", sess);
context.Add("IManExt.Import.FileName", path);
context.Add("ParentWindow", this.Handle.ToInt32());
cmd.Initialize(context);
cmd.Update();
cmd.Execute();
this.Close();
}
shirinp
Thank you for your response. I didnt receive a notification so I didnt know you had responded!
Well, I know that using the importcmd works fine without any problems, as does newprofilecmd. However, I want to be able to capture all the fields that are specified in the new profile dialog. If I use newprofilecmd instead of newprofiledlg, I'm not sure what context item strings to use to set initial fields in the dialog and how to retrieve all of the specified data... is there a list somewhere?
thanks
jny
I'm not sure I completely understand what you're trying to do, but if you're attempting to pre-populate the profile fields through the contextitems for the ImportCmd, there is a technote to show how to do this, which is available at:
https://support.interwoven.com/kb/kb_show_article2.asp?ArticleID=52768
If you want to check on the entered field values anytime during the presence of the new profile dialog, you may use the NewProfileDlg.GetAttributeByID method. This is documented in the VB Scripting for WorkSite Dialogs.pdf. This manual is distributed with the SDK.
shahbm
hi jny,
i m referring to your comment (below) in this article...
"... if you're attempting to pre-populate the profile fields through the contextitems for the ImportCmd, there is a technote to show how to do this, which is available at: "
https://support.interwoven.com/kb/k...ArticleID=52768
- First thing is I counldn't find the above aricle in support kb,
- Second I am trying to do exactly the same thing mentioned above but with the NewProfileDlg through a VBScript..
is this possible?
...
shahbm
hi jny,
i m referring to your comment (below) in this article...
"... if you're attempting to pre-populate the profile fields through the contextitems for the ImportCmd, there is a technote to show how to do this, which is available at: "
https://support.interwoven.com/kb/k...ArticleID=52768
- First thing is I counldn't find the above aricle in support kb,
- Second I am trying to do exactly the same thing mentioned above but with the NewProfileDlg through a VBScript..
is this possible?
...
jny
On this DevNet site, click on the Tech Library tool bar menu. Then, on the left-hand pane, enter the article id, 52768, in the "Look-up by ID" field. You should now be able to see this technote.
Yes, in NewProf.nrs, you can catch the OnChange or OnInitDialog Event to call the SetAttributeValueByID off the dialog object to pre-profile. There is a sample script and the Visual Basic Scripting for WorkSite Dialogs.pdf available in the SDK for your reference.
jny
shirinp -
You may catch the OnChange Event to see which profile field (ID) has just been entered by the end-user. The OnChange Event function has two params: id and obj/dlg. id represents a field in the profile, and obj/dlg is a handle to the New Profile dialog object. You may do something like this to check which field has a value entered in it:
Sub NewProfileDlg_OnChange(obj, id)
if trim(len(obj.GetAttributeByID(id))) <> 0 then
' user has entered a value in this field
msgbox obj.GetAttributeByID(id)
end if
End Sub
The list of attributeID's is available in Table 4.1 AttributeID Enum Values of the Visual Basic Scripting for WorkSite Dialogs.pdf in the SDK.
You can set up a sink to all the newprofile dialog events when you use the ImportCmd to import the document.
To pre-profile specific fields, see example code in the technote for the ImportCmd.
I'm not sure why you would want to capture all the fields in the New Profile dialog. Would you explain your purpose of wanting this?
shahbm
Hi jny,
i think i haven't explained my question correctly.. actually i want to pre-fill some of the fields in new profile dialog..(when user click to copy the document)
in worksite 8.2 it no longer pre-fills the data when u copy a document to make it matter centric, but we have clients who wants some of the fields pre filled with specific data (as in the older versions..)
shahbm
shahbm
jny,
can u tell me how can i get the attributes of selected (nrt)document from desksite, so that i can use setattribute property and use that value..??
Dlg.GetAttributeByID(xyz)- property obly gets the value available from the dialog itself (in copy a document)..
shahbm
jny
You would need to get a handle to the source document object in order to get the attribute values from its profile. The SelectedNRTDocuments ContextItem returns the source document. But, this contextitem acutally returns a safe array of NRTDocument/IManDocument Object Type. So, you would need to get the document object from the array. In newprof.nrs, this is not possible as a safearray cannot not be returned to a Variant - it'll result in Type Mismatch.
If you stay with scripting, specifically newprof.nrs, you could create a helper object that can get the document object out of the array returned by the SelectedNRTDocuments ContextItem. Like so:
[NewProf.nrs]
=========================
Sub NewProfileDlg_OnInitDialog(dlg)
dim hlp
set hlp = CreateObject("SampleFetchContextItems.Helper")
hlp.ContextItems = Context
End Sub
=========================
'COM Component (helper object)
[SampleFetchContextItems.Helper]
=========================
Option Explicit
Private mobjContext As IMANEXTLib.ContextItems
Public Property Let ContextItems(ByVal vNewValue As Variant)
Dim varDoc
Dim doc As IManDocument
Dim sClient As String
Set mobjContext = vNewValue
varDoc = mobjContext("SelectedNRTDocuments")
Set doc = varDoc(0)
' Get description
sClient = doc.GetAttributeByID(imProfileCustom1)
End Property
=========================
Alternatively, you may also replace the default copy command with your custom command -- as I believe that's what you have started and intended to do -- but it would be more involved.