Posts Tagged ‘Tridion’

Get details of item(component,schema etc…) through Buisness Connector in SDL Tridion

October 7, 2010 3 comments

This code helps us to retrieve all the details of a particular item.
I have used Business Connector to connect with sdl tridion.
This code is written in console application(c# .net)

public void Details()
      public StringBuilder stringbuilder = new StringBuilder();

      #region ..item details..
      string path;
      /*this is used to get template from external source,
      for which we have created a folder in our project named as temp
      in that we have a stringTemplate named as */
      path = Environment.CurrentDirectory + "\\temp";

      StringTemplateGroup grp = new StringTemplateGroup("myGroup", path);
      StringTemplate query = grp.GetInstanceOf("folder");

      /* this is to fetch details of the item for which id is specified */
      query.SetAttribute("itemuri", "tcm:88-11828");
      /* this connects to tridion */
      BusinessConnector service = new BusinessConnector();
      service.Credentials = new System.Net.NetworkCredential("administrator", "admin");

      string BC = service.execute("default", query.ToString(), null);

      /*stringbuilder is used to print out put on external file*/

      /*name of the file to which we have to store*/
      File.WriteAllText(@"c:\ShowComponentRaw.xml", stringbuilder.ToString());

      #endregion ..item details...

Here’s the template
/*save it as .st because its string template */

<?xml version='1.0'?>
<tcmapi:Message xmlns:tcmapi=""
version="5.0" from="Nishant" failOnError="false">
<tcmapi:Request ID="Request1" preserve="false">
  <tcmapi:GetItem itemURI="$itemuri$" writeBinaryToDisk="true">
    <tcmapi:ItemFilter type="XMLReadAll"/>

Enjoy.. 😉 ..!!!

Categories: SDL Tridion Tags: , ,
%d bloggers like this: