We have a number of custom scripts that were written in VBScript for SDL Tridion 5.2. These scripts use the TOM API to perform a number of bulk actions on Tridion objects.
Following a recent upgrade to 2011 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 would be 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 to make this sort of change?
Is it as straightforward 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 this could probably be done using the Core Service, but without knowledge of this code or .Net, is it still possible to use VBScript to do this?
Yes, this works in 2011 because the TOM COM+ API is still supported. I recently ran a very similar script on a 2011 system successfully. If you're updating a lot of items you might want to move it to a .net console app because the template or web page might timeout. If you do this then make sure to use marshal.releaseobject for all the TOM objects.
This will work as Robert has stated. If you don't want to enable classic ASP, you could consider putting the code fragment in a Page or Component Template, and then previewing an item with the new template whilst logged in as a privileged user. This will execute the template in the same way. Although if you expect a very long execution time, you will likely get template timeouts similar to the ones that Robert describes for ASP timeouts.
Just make sure to delete or hide your "code" template after you are done.
Related
I am having a hard time with this one and I assume it is something I am missing as always.
I am using Visual Studio Web Express 2012. I have installed Report Builder and Report Viewer 11. I have created a generic report file in the report builder as I can not seem to view any designer view in Visual Studio. Not the issue. I am pulling data from my SQL database as usual and populate a dataset. All is fine from here. I can not seem to get the data to show in the report view but can not figure out what I am missing. I have looked everywhere on the web as well as Stack specifically. I have used some of the sample codes and have gotten the report to now show up but still no data. Any help would be great.
I create a generic report file in report builder. No fields, no title etc., just the generic report. This may be my issue but I can not seem to figure out what I am missing.
On my page load I populate the dataset as always with no problem as I can display the data in a label etc.
I add the report viewer to my page and add the following code to the page load after the dataset fill. I also noted that you must use if page.postback = false as Ajax seems to not like it otherwise and just seems to loop and continue loading forever.
I have tried many different code ideas but found I finally got the report to load (again no data) with the following.
rv1.Reset()
rv1.LocalReport.DataSources.Clear()
Dim rds As New ReportDataSource("DataSet1", tempDS.Tables(0))
rv1.LocalReport.ReportPath = Server.MapPath("\tests\test.rdl")
rv1.LocalReport.DataSources.Add(rds)
rv1.LocalReport.Refresh()
Again this is VB.Net webpage. What am I missing? Thanks in advance.
Did you bind the datasource? Sorry if i'm wrong, but in C# asp.net you need to bind the datasource after using an atribution.
I am running into a problem when creating a SharePoint 2010 Feature. What I am trying to do is:
Check to see if the site name is the same as the site title.
If it isn't, change the name (and therefore the URL) to match the title.
My code is as follows:
Private Sub ChangeSiteNameToMatchTitle()
_web = SPContext.Current.Web
If _web.Name <> _web.Title Then
_web.Name = _web.Title
_web.Update()
End If
_web.Dispose()
End Sub
This successfully changes the name so that it's identical to the site title, but it causes the Feature to crash at the end of it's activation cycle due to the fact that the site name (and therefore the URL) has changed.
The Feature appears to be trying to reload the ManageFeature.aspx page on the site that activated it, but since the URL has changed it cannot find the page any more.
Does anyone know of a workaround for this, or even if it's possible?
Many thanks!
I would make the Feature hidden and activate it outside of the UI using PowerShell.
Also, per best practice rule SPDisposeCheckID_220, you should not dispose SPContext.Current.Web:
SPContext objects are managed by the SharePoint framework and should not be explicitly disposed in your code. This is true also for the SPSite and SPWeb objects returned by SPContext.Site, SPContext.Current.Site, SPContext.Web, and SPContext.Current.Web.
When we are trying to create a new page through a PageType in Tridion UI.It is throwing below error --
"The item tcm:280-29837-64 does not exist."
Is it the Id of the page which i want to create,as it is no more exists in the tridion?
Could any body help me out in this regard ?
Note :-we defined the pagetype to those pages which already exist and published.
Edit-1 When we click on the 'Create Page' button(see the attached screenshot), above mentioned error Pops up.
In the cd_core.log file below error and warning comes --
ERROR XMLConfigurationReader - Error while validating file 'cd_ambient_conf.xml' with schema 'schemas/cd_ambient_conf.xsd'. cvc-complex-type.2.4.a: Invalid content was found starting with element 'ClaimStoreProvider'. One of '{Cookies}' is expected.
WARN AmbientDataContext - There is no current ambient data context - the ambient data framework is not properly initialised
Edit-2 Now errors related to AmbientDataWork are resolved but we are still getting same issue. There are two options in UI (a) "New Page" (b) Create and insert Content. This error also comes when we go with the option "Create and Insert Content". On each click of "Create Page" or "Create and insert Content" it generate a new Id(XXX-59248 -64 then XXX-59249- 64 etc) for page and same way for component also and throws above mentioned error message.
Note:- We are using IIS 6.
Edit-3 - I am using VB script in my page templates.
If someone is using VB script page template,it is required to install UI_2012.0.0.81248 hotfixes to create new pages in UI 2012.
I was not aware about this so fact of using VB script is not mentioned anywhere in the question .So I am updating my question again to assist community member in right direction.
It "looks like" the creation of the page somehow fails on the CM side (but i'm doing an awful lot of interpretation here based on very limited data...).
Can you verify
1. that you can create pages in the content management explorer in the publication with ID 280
2. that your blueprint context settings for UI 2012 are correct (should the new page/component be created in the publication with ID 280?)
3. that you have no workflow or event system interfering with the creation of the page
I would also expect an event log entry in the Tridion/Tridion Content Manager event log which would contain a detailed stack trace...
I am using Tridion 2011 SP1, And I am creating workflow like start-->create-->Review-->publish--Stop.
I created and registered the class library, and invoke the C# method using VBscript (Script Editor of WF Tab) as given below.
Option Explicit
Dim workflowHandler
Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
If Not workflowHandler Is Nothing Then
Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))
FinishActivity "Published to WIP"
End If
Set workflowHandler= Nothing
Is the above code is correct? I am sure I am able to create object using the below line.
Set workflowHandler= CreateObject("CoreComponentWorkflow.WorkflowHandler")
And currently I am publishing the current item only using the C# code, am calling the C# function as below.
Call workflowHandler.PublishComponent(Cstr(CurrentWorkItem.ID))
After publishing the item, I am finishing the activity using below.
FinishActivity "Published to WIP"
I have checked the above code directly in the server by hard coding the currentworkitem, it was working fine. But when I put the same code in vbscript editor, the item is not published.
Can any one suggest on this?
When you hardcode you might be adding the TCM ID directly so it is working properly, which means that CurrentWorkItem.ID is not the correct API call to get the Component ID. See Igor comment below to get the tcm id.
I am trying to track hits to classic asp pages which are used as include files within other asp pages. I am using LogLog as my web analytic tool since I wanted something simple and which runs behind the firewall. What I observed was that LogLog does not track the included files. It will only track the main asp page where I have all the included files. (Note: I have added script to all my .asp files) We want this info so that we can get rid of all unused asp pages in our website which have been lying around for years without anyone using them.
If you want to get rid of unused pages you could try this solution:
add to every asp the following code:
application.lock
aspname = "ASPTRACKER-" + "a.asp" ' Or "b.asp" etc...
if (clng(application(aspname)) = 0) then
application(aspname) = 1
else
application(aspname) = application(aspname) + 1
endif
application.unlock
in your global.asa make sure that the application on end event writes all these application values (starting with ASPTRACKER-) to file....
voila the usage counter of each file
code not tested so there may be a typo...
Using Google Analytics, you track exactly what you want, including specific events or ajax loadings.
You decide when you want to add a hit to the category of your choice, so you can easily add a hit when you load an included page.