This site has been archived and you can no longer log in or post new messages. For up-to-date community resources please visit

eZ Community » Forums » Developer » How to change object attribute in...

How to change object attribute in workflow?

How to change object attribute in workflow?

Sunday 13 May 2012 8:11:35 am - 2 replies

I have one hidden attribute, which cannot be edited by user. That attribute has to be updated depending on what user has enetered in other attributes, and use external webservice to get value.

I made workflow event, and triger it "before publish".

Now i stuck. I have value which has to be set to attribute, but ... how?

Modified on Sunday 13 May 2012 8:12:11 am by Vytautas Germanavičius

Sunday 13 May 2012 11:41:40 am

There are a few ways of doing it...and it really depends on what type of datatype etc.

But this is the easiest example - note this does not create a new version - which depending on what exactly you are doing may or may not be a good idea:

                $attribute->setAttribute('data_text', 'text you want to insert' );

Monday 14 May 2012 7:46:58 am

Remember it is much more appropriate to use the eZContentObjectAttribute API instead of setting attribute's low level persistent object attribute storage contents in the manner shown by Steven.


One side note, remember nodes for objects do not exist until 'after' they are published so at most 'before publish' you can only modify the object and not the node soon to be published (in the given scenario).

Here is an example which uses the eZ Publish kernel API directly to achieve better results overall.

$object = eZContentObject::fetch( $objectID );
$objectDataMap = $object->dataMap();
$objectAttribute = $objectDataMap['class_identifier'];
$objectAttribute->setContent("Variable String Input");

In the above example your using the more popular and accepted setContent method and storeData method which are in most situations better choices for most people. Also remember that the input requirement for a specific datatype's attribute's setContent method are different based on the datatype in question so do your research on the datatype your working with first to ensure you always provide the best input possible.

I hope this helps ...


Modified on Monday 14 May 2012 7:47:52 am by // Heath


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from