AyaScript plugin - Sample Get AyaNova object URL

As documented in the help file but probably not mentioned enough when AyaNova is installed it registers a custom URL protocol AyaNova: with windows which means that windows can open urls that contain links directly to AyaNova objects in your database.

For example if you have AyaNova installed on the same computer as you’re reading this and you have the sample database you would be able to click on the following to open the client record for Great Western Squirrel Supply:

Great Western Squirrel Supply

Since this is an URL it could be on a web page like this one or in a Word document or excel spreadsheet or as a shortcut on your desktop however keep in mind it will only allow the user to open the object if they have AyaNova installed and pointing to the database that contains that object. In other words clicking on the link above would open your copy of Great Western Squirrel Supply, not mine.

Or alternatively if you wanted to open that same client record from another program or batch file you could call AyaNova like this:

“C:\Program Files\Ground Zero Tech-Works Inc\AyaNova\AyaNova.exe” 3,bacd762a-5213-45b9-b4ed-7fd43c80f07d

The format is the integer value of the business object’s RootObjectTypes enum value a comma with no space and then the Guid value of the AyaNova business object which is commonly it’s “ID” property. So in the example above you can see a root object type of Client is 3 and the Guid value for Great Western Squirrel Supply is the rest after the comma.

AyaNova exposes this in the user interface through the right click context menu when you right click on a cell in a grid, however it only exposes a few objects such as clients, workorders, units etc when in fact AyaNova can handle pretty much any object from the command line or as an url.

The following script will generate the correct format type and id links for any object that has the plugins menu option. It defaults to the URL style links but you can comment out those lines and uncomment the others.

It also illustrates using reflection to handle getting a property that is the same across different AyaNova object types without resorting to a huge switch statement and casting.


//Script created: 2/9/2010 10:37:22 AM

//Name: AyaNova object link

//ShowInMenuFor: Everywhere

//HandlesAyaNovaTypes: Nothing

//Display AyaNova url object links suitable for copying and pasting in various styles

public static void AyaScriptMain(bool IsList, RootObjectTypes objectType, Object ayaNovaObject, List<Guid> objectIDList)

{

StringBuilder sb=new StringBuilder();



if(IsList)

{	 

  foreach(Guid id in objectIDList)

  {

	TypeAndID tid=new TypeAndID(objectType,id);

	

	//-------------------------------------

	//Command line parameter style

	//this style used to open AyaNova to a specific object

	//from something like a dos batch file or another program

	

	//Uncomment this line to use this style:

	//sb.Append(tid.ToString());

	

	//-------------------------------------

	//URL style

	//This style used to open an AyaNova object using an URL

	//AyaNova registers the protocol "AyaNova:" with windows when it's installed

	//so you can put these style links in documents etc and click on them like hyperlinks

	//to open the AyaNova object

	sb.Append(tid.ToAyaURLHyperlink());

	

	

	//-------------------------------------

	//Wikipage style

	//This is the style used to open an AyaNova object from within an AyaNova Wiki page

	

	//Uncomment this line to use this style

	//sb.Append(tid.ToAyaURL());		



	sb.Append("\r");

	

	

  }

	

}

else

{

	//Single object, see above for other styles of urls&lt;b