Forum Discussion
Hello,
I only want to use one event type if possible. We are using the connector, however I attempted each type due to the fact that none of them were able to complete the task without issue. The closest and most ideal would be OnAfterUpdate however the office connector throws the error.
Here is the code:
[embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:b1a81315-4fd6-43b6-b279-fd245f1fdff7:type=csharp&text=Innovator%20inn%20%3D%20this.getInnovator%28%29%3B%0D%0Astring%20sourceId%20%3D%20this.getID%28%29%3B%0D%0A%0D%0AString%20relationshipName%3B%0D%0A%2F%2F%2CsouceProperty%2C%20sourceContentLocation%3B%0D%0A%0D%0A%2F%2FItem%20queryFile%2C%20%0D%0AItem%20item%2C%20files%2C%20file%3B%0D%0A%0D%0A%2F%2Ffiletype%20or%20doc%20validation%20if%20reuqired%0D%0Aif%20%28true%29%20%7B%0D%0A%20%20%20%20relationshipName%20%3D%20%22Document%20File%22%3B%0D%0A%0D%0A%20%20%20%20item%20%3D%20this.newItem%28%22Document%22%2C%20%22get%22%29%3B%0D%0A%20%20%20%20item.setProperty%28%22id%22%2C%20sourceId%29%3B%0D%0A%20%20%20%20Item%20isRelationship%20%3D%20this.newItem%28relationshipName%2C%20%22get%22%29%3B%0D%0A%20%20%20%20item.addRelationship%28isRelationship%29%3B%0D%0A%20%20%20%20item%20%3D%20item.apply%28%29%3B%0D%0A%0D%0A%2F%2Fget%20all%20Documet%20Files%20%0D%0A%20%20%20%20files%20%3D%20item.getRelationships%28relationshipName%29%3B%0D%0A%20%20%20%20%0D%0A%20%20%20%20%2F%2FTo%20iterate%20through%20attached%20files%0D%0A%20%20%20%20for%20%28int%20i%20%3D%200%3B%20i%20%3C%20files.getItemCount%28%29%3B%20i%2B%2B%29%20%7B%0D%0A%20%20%20%20%20%20%20%20file%20%3D%20files.getItemByIndex%28i%29%3B%0D%0A%20%20%20%20%20%20%20%20file%20%3D%20file.getRelatedItem%28%29%3B%0D%0A%0D%0A%2F%2Fstring%20to%20be%20added%20into%20filename%0D%0A%20%20%20%20%20%20%20%20string%20stringToRenameFile%20%3D%20this.getProperty%28%22item_number%22%29%20%2B%20%22%20%22%2B%20this.getProperty%28%22name%22%29%20%2B%20%22%20%22%20%2B%20this.getProperty%28%22major_rev%22%29%20%2B%20%22v%22%20%2B%20this.getProperty%28%22generation%22%29%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20string%20fileId%20%3D%20file.getID%28%29%3B%0D%0A%20%20%20%20%20%20%20%20string%20fname%20%3D%20file.getProperty%28%22filename%22%29%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20string%5B%5D%20array%20%3D%20fname.Split%28%27.%27%29%3B%0D%0A%20%20%20%20%20%20%20%20fname%20%3D%20string.Empty%3B%0D%0A%20%20%20%20%20%20%20%20if%20%28array.Length%20%3D%3D%201%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20fname%20%3D%20stringToRenameFile%20%2B%20array%5B1%5D%3B%0D%0A%20%20%20%20%20%20%20%20%7D%20else%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20for%20%28int%20j%20%3D%200%3B%20j%20%3C%20array.Length%3B%20j%2B%2B%29%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fname%20%2B%3D%20array%5Bj%5D%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28j%20%3D%3D%20array.Length%20-%202%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20if%20%28j%20%21%3D%20array.Length%20-%201%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20fname%20%3D%20stringToRenameFile%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20fname%20%3D%20stringToRenameFile%20%2B%20%22.%22%3B%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20%7D%0D%0A%20%20%20%20%20%20%20%20file%20%3D%20this.newItem%28%22File%22%29%3B%0D%0A%20%20%20%20%20%20%20%20file.setAttribute%28%22action%22%2C%20%22RenameFile%22%29%3B%0D%0A%20%20%20%20%20%20%20%20file.setID%28fileId%29%3B%0D%0A%20%20%20%20%20%20%20%20file.setProperty%28%22filename%22%2C%20fname%29%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20%2F%2F%20to%20get%20root%20user%20permission%20via%20identity%0D%0A%20%20%20%20%20%20%20%20Aras.Server.Security.Identity%20identity%20%3D%20Aras.Server.Security.Identity.GetByName%28%22Super%20User%22%29%3B%0D%0A%20%20%20%20%20%20%20%20bool%20permsWasSet%20%3D%20Aras.Server.Security.Permissions.GrantIdentity%28identity%29%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20file%20%3D%20file.apply%28%29%3B%0D%0A%0D%0A%20%20%20%20%20%20%20%20%2F%2Facquired%20root%20user%20permission%20should%20be%20revoked%0D%0A%20%20%20%20%20%20%20%20if%20%28permsWasSet%29%0D%0A%20%20%20%20%20%20%20%20%20%20%20%20Aras.Server.Security.Permissions.RevokeIdentity%28identity%29%3B%0D%0A%20%20%20%20%7D%0D%0A%7D%0D%0Areturn%20this%3B]
I figured it out. Replaced this with item and all is well with onBeforeUnlock.