It's all about the answers!

Ask a question

How to create IVersionablehandle in server side


Yaswanth Garlapati (115) | asked Nov 19, 3:36 a.m.

I have a IFileItem in repository of component, how to get handle of this IFileItem .I only have Ifileitem,getName() value fileName .

Kindly help .

2 answers



permanent link
David Lafreniere (4.8k7) | answered Nov 22, 11:53 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

An IFileItem extends IVersionable, which in turn extends IVersionableHandle.
So if you are saying in your code you have an IFileItem, then you already have the IVersionableHandle.

Or are you saying you only have a String, which represents the name of some file, in which case there's no easy solution, as there could be all sorts of different files in the DB with the same string name.


Comments
Yaswanth Garlapati commented Nov 22, 11:58 a.m.

Actually I want to update a file(next version )that was already in source control how to do that in server side


Yaswanth Garlapati commented Nov 25, 1:30 a.m. | edited Nov 25, 9:15 a.m.

I also have IFolderHandle


David Lafreniere commented Nov 25, 9:29 a.m.
FORUM MODERATOR / JAZZ DEVELOPER

I want to re-emphasize that doing anything based on only a 'file name' is very error prone. There could be multiple different files with the same file name, and also such an approach likely breaks down if the file gets renamed (meaning it could have different names in different streams/branches).

It's really not clear what information you have, and the details of the use case / workflow.

If you are on EWM 7.0.3, you could try looking at IScmQueryService.searchFiles() to see if that helps with your use case.


permanent link
kimon kimasoft (11) | answered Nov 25, 6:07 a.m.

Hello

To get a handle for an IFileItem from its fileName , you can use the repository to find the IFileItem and then convert it to an IFileItemHandle . Here's an example:

IFileItem fileItem = getFileItemByName(fileName); if (fileItem != null) { IFileItemHandle handle = fileItem.getItemHandle(); // Now you can use the handle }

Ensure proper error handling if the file item isn't found. Let me know if you need further help!


Comments
Yaswanth Garlapati commented Nov 25, 6:13 a.m.

Hi, getFileItemByName is a custom method . Do you have any idea of this method?

Your answer


Register or to post your answer.


Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.