locked
How to get the object code for an entity while validating the attached file name? RRS feed

  • Question

  • Hello,

    Can anyone please help me with the solution for the requirement below?

    I need to validate the attached file to an entity with its name, type and size. I could retrieve all the details of the attachment but how to retrieve the object code of the respective entity to perform the validation?

    Thanks & Regards,

    Sri

    Friday, July 3, 2015 7:23 AM

Answers

  • Hi All,

    I could able to find a solution. I used the below statement to get the EntityReference with which performed the validations.

    EntityReference regardingObj =  (EntityReference)attachment["objectid"];

    Thanks,

    Sri

    • Marked as answer by K_Srinivas Friday, July 10, 2015 9:30 AM
    Friday, July 10, 2015 9:30 AM

All replies

  • The annotation entity has objectid which is the unique ID of the record the note/attachment is for, and it also has objecttypecode which is the entity unique name of the record it is for.

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Sunday, July 5, 2015 7:42 AM
  • Hi Paul,

    Thanks for the response.

    Yes, you are correct. I am trying to retrieve the objectid through plugin. But i am not able to get ObjectID because its not objectreference. I am getting error on retrieve statement. Is there a way to retrieve objectid in plugin?

    Thanks & Regards,

    Sri

    Wednesday, July 8, 2015 6:47 AM
  • I believe the ObjectId is an EntityReference... so you should be able to retrieve it normally. What's the error you're getting?

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Wednesday, July 8, 2015 7:08 AM
  • Hi Paul,


    I tried with EntityRefernce and got an error message. So, I checked the database and came to know that objectid is not GUID and its Object Type Code as 1009 (ex:). So, I tried with datatype Int to retrieve the field but still ended up with an error.Please find the error message below.

    Thanks,

    Sri

    Thursday, July 9, 2015 1:39 AM
  • Hi All,

    I could able to find a solution. I used the below statement to get the EntityReference with which performed the validations.

    EntityReference regardingObj =  (EntityReference)attachment["objectid"];

    Thanks,

    Sri

    • Marked as answer by K_Srinivas Friday, July 10, 2015 9:30 AM
    Friday, July 10, 2015 9:30 AM