Running Custom VBScript Pages in SDL Tridion 2011

We have several custom scripts that were written in VBScript for SDL Tridion 5.2. These scripts use the TOM API to perform several bulk actions on Tridion objects.

After a recent upgrade to 2011 Service Pack 1 (SP1), we now have a requirement to change the component template used in a large number of component presentations, and the best way to do this is to run a script to update the necessary pages and component presentations.

Previously, we could run some VBScript similar to the code below to make this change. In 2011, can we still run these scripts for this kind of change?

Is it as simple as enabling classic ASP on the Content Manager server (Windows 2008 R2)?

<% '##### CREATE TRIDION API OBJECTS ##### Set TDSE = Server.CreateObject("TDS.TDSE") Call TDSE.Initialize() '##### CALL FUNCTION - PASS IN STRUCTURE GROUP STARTING POINT ##### Call UpdateComponentTemplates(TDSE.GetObject("tcm:44-39929-4", OpenModeEditWithFallback, "tcm:0-44-1")) Sub UpdateComponentTemplates(arg_strStructureGroup) '##### GET ALL ITEMS WITHIN SPECIFIED STRUCTURE GROUP ##### For Each objItem In arg_strStructureGroup.GetItems '##### IF ITEM IS A STRUCTURE GROUP ##### If TypeName(objItem) = "StructureGroup" Then '##### CALL THE FUNCTION AGAIN, PASSING IN THE STRUCTURE GROUP ##### Call UpdateComponentTemplates(objItem) End If '##### IF ITEM IS A PAGE ##### If TypeName(objItem) = "Page" Then For Each objComponent In objItem.ComponentPresentations '##### CHECK EXISTING COMPONENT TEMPLATE & UPDATE WITH THE NEW ONE ##### If objComponent.ComponentTemplate.ID = "tcm:44-493-32" Then 'objComponent.ComponentTemplate = "tcm:44-216181-32" 'objItem.Save(True) '##### OUTPUT STATUS MESSAGE ##### Response.Write(objItem.Title & " ......................... UPDATED<br />") & vbCrlf Response.Flush() End If Next End If Next End Sub Response.Write("<p>Job Done!!!</p>") & vbCrlf '##### CLEAN UP OBJECTS ##### Set TDSE = Nothing %> 

I know that this could probably be done using the Core Service, but without knowing this code or .Net, is it possible to use VBScript for this?

+4
source share
2 answers

Yes, this works in 2011 because the TOM COM + API is still supported. I recently successfully used a very similar script on a 2011 system. If you are updating a lot of elements, you can transfer them to the .net console application, because the template or web page may timeout. If you do, be sure to use marshal.releaseobject for all TOM objects.

+5
source

This will work as Robert stated. If you do not want to include classic ASP, you can consider placing a piece of code in the page or component template, and then previewing the element with the new template during login as a privileged user. This will cause the template to be executed in the same way. Although, if you expect very long runtimes, you will most likely get pattern timeouts similar to those described by Robert for ASP timeouts.

Just make sure you delete or hide your code template after completion.

+2
source

All Articles