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

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

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 folder.st */
      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="http://www.tridion.com/ContentManager/5.0/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: , ,
  1. Shalini
    October 11, 2010 at 5:24 am

    Nice blog dear.I liked it.

  2. February 7, 2012 at 3:25 pm


  3. February 18, 2012 at 7:06 am

    The code “Environment.CurrentDirectory”, returns the path of “\bin\Debug” directory of the project. So create you folder that contains the “String template” in “\bin\Debug” directory.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: