Phil - Tuesday, February 9, 2010 1:52 PM:
So, here is the situation fellow Aras folks. I have certain ItemTypes, that have related Files. These files need to be stored in their own vault per business rules.
So my question is, what would be the best/easiest way to make it so that certain ItemTypes are setup as to when their Files are added (regardless of what user adds them) they are automatically sent to a specific vault.
My immediate thought is the only way to accomplish this is to setup a method that fires when the files are added that then specifies the vault I want to store them in...but I am not sure if this is possible as I thought the vaults were based on the User?
Thank you all for your help!
Phil - Tuesday, February 16, 2010 12:15 PM:
So, I thought I had this all figured out....here was my brilliant scheme:
1. For the ItemType I wanted stored in a specific vault, I added an onBeforeAdd server event.
2. In this event, I changed the logged in users default vault to the vault I wanted the files stored in.
3. I also added an onAfterAdd event for the ItemType that changed the user's default vault back to the Default vault.
I really thought this would work.....however, I should have known better. There seems to be some Session variable work at play here. It seems as if though there is a session variable set for the user's vault when they log in. This session vault variable is probably persisted until the user logs out. If I could only find the name of said session variable...I would toggle it in my method..... So now, I am performing a Windows GREP to see if I can sleuth the name out that way somehow.
If anyone out here knows the name of said variable, or would like to provide any insight...please help!
Phil - Tuesday, February 16, 2010 2:38 PM:
After some more poking about, I still have not found how to remedy this issue.
I looked at the session variables, and none of them contain any reference to a vault. However, if you change a user's vault whilst logged in, the change does not take effect until after you log out and log back in. So its obvious that the default vault is getting stored somewhere (if not the session) upon login.
My question is : where is this stored, or better yet...how to "refresh" these settings without logging out ?
Phil - Tuesday, February 16, 2010 3:53 PM:
OK, I have given up on the hope of temporarily changing the user's default vault. I can't seem to find a way to do accomplish that.
So here is my new idea: For the ItemType create a SERVER method (onBeforeAdd) that performs the following:
------------------------- BEGIN CODE --------------------------------------------------------------
Innovator myInnovator = this.newInnovator();
string strAML = this.dom.InnerXml;
string strDefaultVault = "<related_id keyed_name="Default">67BBB9204FE84A8981ED8313049BA06C</related_id>";
string strSBUVault = "<related_id keyed_name="VaultSBU">97EF23C063494398BDC87A13AEB05073</related_id>";
strAML = strAML.Replace(strDefaultVault,strSBUVault);
this.loadAML(strAML); //load the new aml
//*********Write aml to file to see if its right or not*****************
string path = HttpContext.Current.Server.MapPath("temp/aml.txt");
try
{
StreamWriter sw = File.CreateText(path);
sw.Write(this.dom.InnerXml);
sw.Close();
}
catch(Exception ex)
{
return myInnovator.newError(ex.Message);
}
// *********************END OF WRITING TO FILE ************************
return this; //return the changed item
--------------------------------------------END OF CODE --------------------------------------------------------------
Once again, this does not even work. When I examine the AML in the file, after I apply it, it looks correct. But when the files are added, they are still added to the Default Vault! Does the AML change not make it to the server adding the item?
Phil - Wednesday, February 17, 2010 10:16 AM:
Come on folks! I know someone around here has had to have used the onBeforeAdd server event to modify the context item before adding it to the system. I thought that was one of the primary purposes of the event? What am I missing here?
RobMcAveney - Wednesday, February 17, 2010 11:03 AM:
Hi Phil -
Requests to vault a file go to the vault server first, then on to the Innovator server, so a server event is going to run after the file is already vaulted. I think you need to do something client-side to change the vault before the request is sent. I don't have sample code handy, but I'll try to get you something soon.
Rob
Phil - Wednesday, February 17, 2010 11:19 AM:
That would definitely explain why modifying the context item's aml before the Innovator Server add seems to make no difference. I can't even think of any client events I could use (either on the form or the ItemType), that would expose the Item's AML for changing (as in my code above).
RobMcAveney - Wednesday, February 17, 2010 12:07 PM:
Looks like the client is not checking the Located relationship before it vaults the file and just uses the User's default vault. I'll file that as an issue. If you can't wait for that to get fixed you'll have to resort to modifying the client javascript that retrieves the vault server URL (not suggested or supported). Sorry I couldn't help more.
Rob
Phil - Wednesday, February 17, 2010 12:12 PM:
Crap, I have a feeling I just contributed to getting the next open release pushed back further!
If you would kindly point me to the appropriate javascript file you are referring to, I would appreciate it....even if you don't recommend it.
Since you are saying that the files are vaulted in the users default vault no matter what, would my initial idea of temporarily changing the user's default vault work? I toyed around with that method for a while, but I could not get Innovator to recognize the default vault change until I logged out and logged back in?