For a complete list of my blogs regarding content management, please see here.
In our CRM social integration project we extract the picture of one tweet from twitter website and store them in CRM system as attachment.
We are creating attachment in CRM via the approach described in this blog.
However, we found the Create by property for an attachment is always hard coded with sy-uname, even we explicitly specify the created_by property when calling
cl_crm_documents=>create_with_table. However our requirement is it should be filled by the screen name in twitter website who posts the tweet.
After some debugging I found the created_by property could only be modified after the attachment is created.
First I query all attachments of a given tweet:
CALL METHOD CL_CRM_DOCUMENTS=>get_info
BUSINESS_OBJECT = ls
LOIOS = LOIOS
phios = phios.
Then I use FM SDOK_PHIO_PROPERTIES_SET to change the property
APPEND ls_property TO lt_properties.
ls_header-class = <ios>-class.
ls_header-objid = <ios>-objid.
CALL FUNCTION 'SDOK_PHIO_PROPERTIES_SET'
object_id = ls_header
properties = lt_properties
NOT_EXISTING = 1
BAD_PROPERTIES = 2
NOT_AUTHORIZED = 3
EXCEPTION_IN_EXIT = 4.
I have put the code into a utility class and test it:
And that's done:
Never forget to activate internal mode, or else you will fail with an error message that created_by field is read only.