How to use getid() method to get id?

In the system the "Id", and "config-id" are the item name. For Document item, the id is the document name(screenshot below).  I need the id property, the one that is unique, to be added to the properties of Document item. 

I have this method but it doesn't work:
Item myItem = this.newItem("Document");
myItem.setID(this.getID());
Item results = myItem.apply();

Error is "Error Number: CS0161, 'ItemMethod.methodCode()': not all code paths return a value"

Also, once I have this method working what are the next steps. I guess I will have to add this method to the Server Events, event onBeforeGet, correct?

Any help is appriciated. 

Thanks!

Parents
  • Hi Hargul,

    I think your error is not related to your use of getID(). The error specifies that your code doesn't return properly. Make sure your method ends with the return of an item, or if you only need to return a string you can return inn.newResult("STRING");

    For what you're trying to achieve, I am not sure I understand the use case. Are you trying to modify the document and set the ID to a different property? With more context I believe I could better help you here. 

    AJ

  • Hi AJ, thanks for replying. The issue is that there is no property of the Document item that has a "ID" . The id are just the Document item_number(screenshot below). I want the unique IDs, the value in <id> tag, to be displayed in the search grid. I don't want to change the current Data Source of the ID property. I want to add a new property, say GUID, that will show the unique id in the search grid.

Reply
  • Hi AJ, thanks for replying. The issue is that there is no property of the Document item that has a "ID" . The id are just the Document item_number(screenshot below). I want the unique IDs, the value in <id> tag, to be displayed in the search grid. I don't want to change the current Data Source of the ID property. I want to add a new property, say GUID, that will show the unique id in the search grid.

Children