Don't find document or assignements when right click on task

Hi everyone,

I have a task like that (sorry it's in french) :

I want to add a button in the right click menu only if the task contains a file.

I know how to add a button on right click and how to hide it when I want. But, I failed to know if the task have a file.

This is what I use actually:

// function called when creating right click menu
shellListing.Events.Register(Event_ShowContextMenu, function (selectedItems) {
    if(selectedItems.Count == 1 && selectedItems.ObjectVersions.Count == 1) { // check if there is a document, never true when right clic on task. That's my issue
	    var objVerSelected = selectedItems.ObjectVersions[0];
		var vault = shellFrame.ShellUI.Vault; // get vault
	    if(objVerSelected.HasAssignments && vault.ClassOperations.GetObjectClass(objVerSelected.Class).ObjectType == 10) { // check if it's a task
	        // I want to show it
	    } else {
	        // don't want to show it

In my code, the task verfification (to check the Type object) work perfectly. The way to get file work when you right click on document but not when on a task link to document.

Also, `HasAssignments` is always false.

How can I do ?