Script failure when trying to retrieve clickData.func.sourcetab

Hi Opus,
can you assist in remedying this problem ?

Thx, Brian

Error at line 86, position 2
Object required: 'clickData.func.sourcetab' (0x800a01a8)

Option Explicit
Function OnClick(ByRef clickData)
	' This is the default example OnClick script, to help get you started.
	' (You can use the "Default" menu above to replace this with your own default.)
	' 
	' Some essentials (see Scripting Reference in the manual for the rest):
	' - clickData.func.command:
	'     Command object.
	'     Preconfigured with source, destination and selected items.
	'     To change source/dest:
	'       cmd.SetSource, .SetSourceTab, .SetDest, .SetDestTab.
	'     To change files/folders acted upon:
	'       cmd.ClearFiles, .AddFile, .AddFilesFromFile, .RemoveFile, etc.
	'     To run a simple, single-line command:
	'       cmd.RunCommand "Help ABOUT"
	'     To run a multi-line command:
	'       cmd.Clear
	'       cmd.AddLine "Help ABOUT"
	'       cmd.AddLine "Help LICENCEMANAGER"
	'       cmd.Run
	' - clickData.func.Dlg
	'     Dialog object for showing message boxes and other UI.
	'     Preconfigured with the source tab as its parent window.
	' - clickData.func.sourcetab and .desttab:
	'     Source and destination folder tabs.
	'     Access to data such as:
	'       tab.selected, .selected_dirs, .selected_files.
	'       tab.all, .dirs, .files.
	'       tab.path (tab's folder path).
	'       tab.lister (top-level lister that contains the tab).
	'       tab.right (tells you if tab is on the left or right).
	'       etc.
	' ---------------------------------------------------------
	DOpus.ClearOutput
	Dim cmd, lister, tab, selItem, folderEnum, folderItem
	dim doCmd
	' ---------------------------------------------------------
	Set cmd = clickData.func.command
	cmd.deselect = false ' Prevent automatic deselection
	

	dim str_sourcePath
	dim str_folder_driveLetter, str_remaining_folderPath
	dim str_sharePoint_URL, str_Cmd
	dim trace

trace = true

doCmd = true

	str_sourcePath = clickData.func.sourcetab.path
	str_folder_driveLetter   = ucase(left(str_sourcePath, 1))
	str_remaining_folderPath = mid(       str_sourcePath, 3)
	if trace then DOpus.Output  "str_folder_driveLetter   : " & str_folder_driveLetter
	if trace then DOpus.Output  "str_remaining_folderPath : " & str_remaining_folderPath

	select case str_folder_driveLetter
		case "R"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/SolutionandProjectServices-Projects/Shared%20Documents/General/" 
		case "S"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/SPSIntegrationandCapabilityTeam/Shared%20Documents/General/" 
		case "T"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/2021TestingMaturationandConsultation/Shared%20Documents/General/"
		
	case else : 
doCmd = false ' goto unknownFolder_ie_notMapped_inSharepoint
	end select

if doCmd then
		str_sharePoint_URL = str_sharePoint_folderPath & str_remaining_folderPath
		if trace then DOpus.Output  "str_remaining_folderPath : " & str_remaining_folderPath
	
		str_Cmd = DOpus.Vars.Get("opus_dopusrt")  & " /runstd " & str_sharePoint_URL
		cmd.RunCommand str_Cmd
	'	DOpus.Vars.Get("opus_dopusrt")  /runstd str_sharePoint_URL
	'   {$glob:opus_dopusrt} /runstd str_sharePoint_URL
end if

'                     unknownFolder_ie_notMapped_inSharepoint: ' <<=== {sourcePath} is not mapped to sharepoint
	 			                                               ' qq notify the user, TBD


	
End Function

Path is an object, and VBScript is a bad language that requires different syntax if you want to store an object reference.

Instead of this:

str_sourcePath = clickData.func.sourcetab.path

Try this:

Set str_sourcePath = clickData.func.sourcetab.path

Hi Leo,
thx, I tried that, but it didn't solve the problem.
In attempting to do that, and avoid vbScript problems,
I rewrote the script in JScript, the code is below.

However, retrieving clickData.func.sourcetab.path returns undefined,
so this I can't solve myself, could you please advise how to
resolve this ? The code follows.

The relevant code line is:

     	str_sourcePath = clickData.func.sourcetab.path;
	if (trace) { DOpus.Output  ("str_sourcePath   : `" + str_sourcePath + "`."   ); }

and the Dopus.Output gives:

        str_sourcePath   : `undefined`.

Thx, Cheers
Brian

function OnClick(clickData)
{
	// This is the default example OnClick script, to help get you started.
	// (You can use the "Default" menu above to replace this with your own default.)
	// 
	// Some essentials (see Scripting Reference in the manual for the rest):
	// --------------------------------------------------------
	DOpus.ClearOutput();
	// --------------------------------------------------------
	var cmd = clickData.func.command;
	cmd.deselect = false; // Prevent automatic deselection

	var str_sourcePath;
	var str_folder_driveLetter, str_remaining_folderPath;
	var str_sharePoint_URL, str_Cmd;
	var trace;

trace = true;
doCmd = true;

	str_sourcePath = clickData.func.sourcetab.path;
	if (trace) { DOpus.Output  ("str_sourcePath   : `" + str_sourcePath + "`."   ); }

//	str_folder_driveLetter   = clickData.func.sourcetab.path.substr(1, 1).toUpperCase();
	str_folder_driveLetter   = str_sourcePath.substr(1, 1).toUpperCase();
	str_remaining_folderPath = str_sourcePath.substr(3, 999);

//			str_remaining_folderPath = 'Work_Structure_and_ALM\\ALM_Config\\ALM_ConfigMgt'

	if (trace) { DOpus.Output  ("str_folder_driveLetter   : " + str_folder_driveLetter   ); }
	if (trace) { DOpus.Output  ("str_remaining_folderPath : " + str_remaining_folderPath ); }

//			str_folder_driveLetter = "T";

	switch (str_folder_driveLetter)
	{
		case "R"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/SolutionandProjectServices-Projects/Shared%%20Documents/General/" ;
					break;
		case "S"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/SPSIntegrationandCapabilityTeam/Shared%%20Documents/General/" ;
					break;
		case "T"  : str_sharePoint_folderPath = "https://westernsydneyedu.sharepoint.com/:f:/r/sites/2021TestingMaturationandConsultation/Shared%%20Documents/General/";
					break;
	default : 
doCmd = false; // goto unknownFolder_ie_notMapped_inSharepoint
	}

	if (trace) { DOpus.Output  ("str_sharePoint_folderPath   : " + "\n" + str_sharePoint_folderPath   ); }

if (doCmd) {
		str_sharePoint_URL = str_sharePoint_folderPath + str_remaining_folderPath;
		if (trace) { DOpus.Output ( "str_remaining_folderPath : " + str_remaining_folderPath ); }
		if (trace) { DOpus.Output  ("str_sharePoint_URL   : " + "\n" + str_sharePoint_URL   ); }
	
		str_Cmd = DOpus.Vars.Get("opus_dopusrt")  + " /runstd " + str_sharePoint_URL;
		cmd.RunCommand(str_Cmd);

	// qq put the sharepoint-URL into the ClipBoard
}

//                     unknownFolder_ie_notMapped_inSharepoint: ' <<=== {sourcePath} is not mapped to sharepoint
	 			                                               // qq notify the user, TBD
	
	// --------------------------------------------------------
}

Does this work for you? It works for me:

function OnClick(clickData)
{
	var str = clickData.func.sourcetab.path;
	DOpus.Output("str: `" + str + "`");
}

no, I get
str: undefined

that may also explain why the vbScript version didn't work

How are you running it?

I had it configured to run as a hotkey.

When i put it as a command on a toolbar,
it worked. I have no idea why.
The failure occurred when i was running the code from edit using F5.

Only now, I don't know why I'm getting the following;
can u help with this as well,

str_sourcePath = clickData.func.sourcetab.path;
if (trace) 
{ 
DOpus.Output  ("str_sourcePath   : `" + str_sourcePath + "`."   ); 
}

===>>> str_sourcePath : C:\uDrive\sw.

str_folder_driveLetter = slice(str_sourcePath,1, 1);
Error at line 95, position 2
Object expected (0x800a138f)

str_folder_driveLetter = str_sourcePath.slice(1, 1);
Error at line 95, position 2
Object doesn't support this property or method (0x800a01b6)

slice and substr both fail, prefixing with string. also doesn't work.

Cheers,
Brian

In the above code str_sourcePath is an Opus Path object; if you want to use string methods on it you need to convert it to a string,

e.g. str_sourcePath = clickData.func.sourcetab.path + "";