How to get the current component TCM id in workflow? - tridion

I am trying to get the current component TCM id (component which entered in the workflow) with the VBscript given below, but am not getting the Component TCM id
(something like tcm:56-1567)
I tried to use the below code, it gives the id like tcm:56-363-131200
processingitem = CurrentWorkItem.ID
And tried like the below code, it gives the id like tcm:56-195-131076
processingitem = CurrentWorkItem.ActivityInstance.ProcessInstance.ID
And tried like the below code, it doesnt give anything.
processingitem = CurrentWorkItem.GetItem()
processingitem = CurrentWorkItem.GetItem(2)

It should be: CurrentWorkItem.GetItem(2).ID. What does it return for you?

Related

How to get the type of a field via Javascript : Google App Maker

How do I get the field type of a field in Google App Maker?
I have tried to find it via:
app.models.MODEL_NAME.fields.date
but there isn't a property type for a field.
So the question is how can I find the type of a field via Javascript?
Many thanks
Interesting question. Here is how I do it; Suppose I want to know what are all the field types of a model. I use this:
var allFields = app.models.MODEL_NAME.fields._values;
for( var f=0; f<allFields.length; f++) {
var field = allFields[f];
var fieldType = field.__gwt_instance.b.B.j;
console.log(fieldType);
}
So, in summary, all you have to do is get the field:
var field = app.models.MODEL_NAME.fields.DESIRED_FIELD
Then you just get the type like this:
var fieldType = field.__gwt_instance.b.B.j;
As I say, this works for me. I hope this works for you too!
There is also a less cryptic attribute that will give you the field type (although it only works in server scripts):
app.metadata.models.MODEL_NAME.fields.DESIRED_FIELD.type;

2sxc Relationship Filter without EntityTitle

I'd like to use the relationship filter to filter for a tags. This works fine when I pass a text string and it can search the EntityTitle, but I'd like to pass an entity_id to the filter.
I noticed in the details of the query results that the relationship filter has a "CompareAttribute=EntityTitle". Is there a way to edit that to make it EntityID?
Thanks.
At the moment filtering by a different property in related items could only be done in code. Heres' how
create your visual query as you would, with the only "mistake" being the wrong field
in your razor template, access the Query with var q = App.Query["queryname"];
then before you get the data, change the CompareAttribute. This will take a bit of fiddling about, because you have to cast the q from before to a IDataTarget and navigate up the query-tree like var relFilter = q.In["Default"].Source, then cast that again to the right type, and then change the relFilter.CompareAttribute = "Country";
...something like that :)
Afterwards you can access the query results with a foreach(var x in AsDynamic(q["Default"])) {...}
I've tried this where I wanted some locations grouped by region,
So I did:
region 1
address 1
address 2
region 2
address 3
address 4
So basically it should do the same except it would query by region.
So this is what I came up with:
#{
var someAddresses = App.Query["FilterAddresses"]["ListContent"];
someAddresses.Filter = region.RegionName;
Data.In.Add("someAddresses", someAddresses["Default"]);
}
#foreach (var pc in AsDynamic(someAddresses.List)) {
<li>#pc.Naam</li>
}
However it says:
CS1061: ToSic.Eav.DataSources.IDataStream does not contain a definition for Filter.
So should it be something else?

Get Publication "Title" from IdentifiableObject in tridion2011 events

I have an Tridion.ContentManager.IdentifiableObject which may be a Page/Component etc and I wish to get the title of the publication it belongs to.
I am current able to get the publicationId like so:
IdentifiableObject.Id.PublicationId
but I wish to get the Publication title without doing a round trip to tridion. Is this possible?
It is possible. First of all cast your object to RepositoryLocalObject instead of IdentifiableObject and then you can do:
var item = (RepositoryLocalObject) subject;
item.OwningRepository.Title;

SDL Tridion GetListKeywords using Anquilla Framework

I'm writing a GUI extension and using the Anquilla framework to get a list of Keywords within a Category. I'm obtaining an XML document for the list of keywords then working with that document within my extension.
My problem is that the returned XML doesn't contain the Keyword's 'Description' value. I have the Title and Key etc.
My original code looks like this:
var category = $models.getItem("CATEGORYTCMID:);
var list = category.getListKeywords();
list.getXml();
A typical node returned is this:
<tcm:Item ID="tcm:4-1749-1024"
Type="1024" Title="rate_one" Lock="0" IsRoot="true"
Modified="2012-12-17T23:01:59" FromPub="010 Schema"
Key="rate_one_value" IsAbstract="false"
CategoryTitle="TagSelector"
CategoryID="tcm:4-469-512" Icon="T1024L0P0"
Allow="268560384" Deny="96" IsNew="false"
Managed="1024"/></tcm:ListKeywords>
So I've tried using a Filter to give me additional column information:
var filter = new Tridion.ContentManager.ListFilter();
filter.columns = Tridion.Constants.ColumnFilter.EXTENDED;
var list = category.getListKeywords(filter);
Unfortunately this only gives the additional XML attributes:
IsShared="true" IsLocalized="false"
I'd really like the description value to be part of this XML without having to create a Keyword object from the XML. Is such a thing possible?
cough any ideas? cough
I'm afraid you'll have to load the Keyword itself to get the Description.
It's not used in any lists, so it's not returned in the XML.
You could always create a List Extender to add this information to the list, but try to be smart about it since this extender will execute everytime a GetList is called.
Won't save you from having to open every keyword in the list, but you'll be doing it server-side (with Core Service/NetTcp for instance) which will probably be easier and faster than opening each keyword with Anguilla.
In this instance I only need the one keyword, so I simply get it from the CMS. Getting an object in Anguilla is a bit weird, here's the code:
In your main code area:
var selectedKy = $models.getItem("TcmUriOfKeywordHere");
if (selectedKy.isLoaded()) {
p.selectedKy = selectedKy;
this.onselectedKyLoaded();
} else {
$evt.addEventHandler(selectedKy, "load", this.onselectedKyLoaded);
selectedKy.load();
}
It's worth noting how I store the keyword in the properties of the item, so I can obtain it in the onselectedKyLoaded function
The function called once the item is loaded
ContentBloom.ExampleGuiExtension.prototype.onselectedKyLoaded = function (event) {
var p = this.properties;
var selectedDescription = p.selectedKy.getDescription();
// do what you need to do with the description :)
};
I resolved this, thanks to the answer here: https://stackoverflow.com/a/12805939/1221032 - Cheers Nuno :)

How to get generated HTML-ID-Attribute from Symfony2-Form-Elements

I want to receive Error-Messages from a Symfony2-Form via ajax (JSON). Now I get the problem to join the $form_element->getName() with my form-element ID in HTML. Is there a possibility to get this ID from the $form_element-Object?
Yes, simply use
$form->get('field_name')->createView()->vars['id'];
In order to get view related data (like id and class options) from a form, first you have to create its view.
You can also do it the other way:
$formView = $form->createView(); // Creates view for every element of the form
$id = $formView->children['field_name']->var['id'];

Resources