Skip to main content

Reports From SamurAI Are Owned by the Person Who Asked (CRM)

When a staff member asks SamurAI for a report, the CRM now saves that report under the staff member's own name, not under the SamurAI service account. SamurAI tells the CRM who asked by sending that person's user id when it creates the report.

Contents

1. Before You Start

2. What Changes in the CRM

3. Create a Report for a User

4. What the CRM Sends Back

5. All Cases and Their Results

6. Updating a Report

7. Frequently Asked Questions

1. Before You Start

You will need:

  • A session for the SamurAI service account, the same one SamurAI uses today (the sessionName from the login call).

  • The CRM user ID of the staff member talking to SamurAI. It is the same id SamurAI already sends when it checks that person's SamurAI permissions, and it can be sent in either form: plain ( 25 ) or the webservice form ( "19x25" ).

Access requirements: only the SamurAI service account can create a report on behalf of another user. Any other API user can still create reports, but they always own them.

There is nothing to switch on in the CRM, and no new screen or setting. The change only needs the new CRM release on the instance. If the user_id is sent to an instance that doesn't have the release yet, the instance ignores it and creates the report as before.

2. What Changes in the CRM

Where

Before

Now

Reports list, Owner

The SamurAI service

account

The staff member who asked SamurAI

Opening and editing the report

The report looked like

someone else's

The staff member can open and edit it like a report they built themselves

Who else can see it

Decided by the report's

sharing

Unchanged: still decided by the report's sharing

Tip: owning a report does not give anyone access to more records. A report always shows only the records the person viewing it is allowed to see.

3. Create a Report for a User

Send the same createreport call as today, with one extra key, user_id :

POST {instance}/crm/restapi.php/createreport?sessionName=<sessionName>

{

"name": "Leads by Source",

"user_id": 25,

"primary_module": "Leads",

"columns": ["Leads.First Name", "Leads.Lead Source"],

"group_by": [{ "field": "Leads.Lead Source", "sort": "count_desc" }],

"chart": { "type": "pieChart", "group_by_field": "Leads.Lead Source", "data_fields": ["count(*)"] }

}

The webservice form works the same way: "user_id": "19x25" .

Key

Description

Example

user_id

The CRM user who requested the report from SamurAI. That user becomes the owner. Optional.

25 or

"19x25"

4. What the CRM Sends Back

The response now also includes owner_id, the ID of the user who owns the new report. The other keys are unchanged.

{ "success": true,

"result": { "report_id": 812,

"folder_id": 29,

"url": "{instance}/crm/index.php?

module=Reports&view=ChartAndDetail&record=812",

"owner_id": 25 } }

5. All Cases and Their Results

Who calls

user_id sent

Result

SamurAI

an active user ( 25 or

"19x25" )

Report created and owned by that user

SamurAI

nothing, "" or null

Report created and owned by SamurAI, as before

SamurAI

its own id

Report created and owned by SamurAI

SamurAI

not an id ( "abc" , 0 ,

"25abc" )

Error INVALID_INPUT

SamurAI

an inactive user

Error INVALID_INPUT

SamurAI

a deleted or unknown user

Error RECORD_NOT_FOUND

Any other API

user

nothing, or its own ID

Report created and owned by that user, as before

Any other API

user

someone else's ID

Error ACCESS_DENIED

When a call is rejected, nothing is saved. Example of a rejected call:

{ "success": false,

"error": { "code": "ACCESS_DENIED",

"message": "Only the SamurAI service account may create a report on behalf of another user." } }

6. Updating a Report

updatereport never changes the owner. If user_id is sent on an update, it is ignored, and the report keeps the owner it was created with.

SamurAI can still update a report it created for someone else, because the SamurAI service account keeps edit access to it.

7. Frequently Asked Questions

Q: What happens if SamurAI does not send user_id? Nothing changes: the SamurAI service account owns the report, exactly as before this release.

Q: Which folder does the report go into? The same as before. If no folder is given, SamurAI's reports go into the "SamurAI" folder. The owner does not affect the folder.

Q: Can the staff member change the report? Yes. They can open and edit it like any report they created themselves.

Q: Does the owner get to see records they could not see before? No. A report always runs with the permissions of the person viewing it.

Q: Does the order of the SamurAI release and the CRM release matter? No. The CRM ignores user_id until its release is in place, and SamurAI keeps working either way.

Need Help?

If you run into issues:

1. Check the error code and message returned by createreport: they name the exact problem, for example, an inactive user.

2. Confirm the user_id belongs to an active CRM user on that same instance. 3. Contact Dazos support with the request, the response, and a reference to CRM-3793.

Did this answer your question?