Create Linked CB Gallery Media Items

6 months 3 weeks ago #335321 by krileon
Replied by krileon on topic Create Linked CB Gallery Media Items
I'm not sure. I've just tested the above and it's working perfectly fine in my tests. Specifically I created the below test.

Global
Triggers: None
Type: CB Gallery
User: Self
Access: Everybody
Action
Mode: Item
Method: Create
Asset: profile.[user_id]
Link: LIVE_IMAGE_PATH_HERE
Title: Test
Owner: [user_id]
Load: By Asset, Link, and Owner
Output
Display: JSON
Layout:
if ( ! $actiondata['data1'] ) {
    return [];
}

return [    'id'        =>    $actiondata['data1']->getInt( 'id' , 0 ),
            'user_id'    =>    $actiondata['data1']->getInt( 'user_id' , 0 ),
            'asset'        =>    $actiondata['data1']->getString( 'asset' , '' ),
            'date'        =>    $actiondata['data1']->getString( 'date' , '' ),
        ];
Method: PHP

This then gave me the following results.
{"id":30655,"user_id":1090,"asset":"profile.1090","date":"2023-09-18 14:15:01"}

So it seams to be working.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

6 months 3 weeks ago #335323 by PaceOnline
Replied by PaceOnline on topic Create Linked CB Gallery Media Items
I have copied exactly that and I still get "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data"

Please Log in to join the conversation.

6 months 3 weeks ago - 6 months 3 weeks ago #335325 by krileon
Replied by krileon on topic Create Linked CB Gallery Media Items
My guess is you've a JSON error coming from something else or something is messing with the output buffer data maybe. Is the gallery media item being created?

It's possible something installed on your site could be messing with headers. Try adding &format=json or &format=raw to your auto action URL.

Aside from that I recommend checking your server error log to see if there's any further details regarding your error as without a callstack showing where it's coming from there's nothing more I can suggest and since tests can't reproduce it it seams to be a problem in the environment and not a bug in CB Auto Actions.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.
The following user(s) said Thank You: PaceOnline

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.204 seconds

Facebook Twitter LinkedIn