Updating thread author in ForumThread.BeforeCreate with automation not working

Hi,

I have an automation which is fired based on an API event of ForumThread.BeforeCreate which should change the author when certain conditions are met.  I know that the automation is taking place as I also update the subject which is being applied, however, when changing the author, it seems to be ignored/dropped.

I have checked the documentation which states that the 'Author' property is available for read and write so assume that this would be possible?

Is anyone able to advise if this is possible via automation please?

I am using version 12.0.3.17950.

Any help is, as always, greatly appreciated.

Thanks,

James.

Parents Reply Children
  • One option may be to customise the widget and rather than using the current call to create in save.vm

    #set($threadOrReply = $core_v2_forumThread.Create($forumId, $subject, $body, $options))

    You could add a new saveas.vm to the widget containing the line above and call that using the execute as method passing in your shadow author value 

    #set($response = $core_v2_widget.ExecuteFile("saveas.vm" "%{ RunAsUserName = "newauthor" }"))

    #set($threadOrReply = $core_v2_forumThread.Create($forumId, $subject, $body, $options))
    #set($threadId = $threadOrReply.Id)
    
    {
    	#if (!$threadOrReply.Approved)
    		"redirectUrl":"$core_v2_encoding.JavascriptEncode($core_v2_forumUrls.PendingModeration($forumId))"
    	#else		
    		"redirectUrl":"$core_v2_encoding.JavascriptEncode($threadOrReply.Url)"
    	#end
    }


    You would also need to think about how you handle the output from the called saveas.vm file and how its passed back to the calling javascript re the redirect url etc 

    Its not clear from the documentation if all the existing variables are passed into the executed file when executing as another user, it did seem to work when I quickly tried it locally 

    Another more involved method would be to create a backend scripted fragment if that is an option, I have done this recently to allow for a shadow author