mattkol / SugarRestSharp

SugarRestSharp is a .NET C# SugarCRM/SuiteCRM Rest API Client. It is .NET C# Wrapper for the SugarCRM/SuiteCRM REST API Client.
MIT License
30 stars 12 forks source link

Put a meeting on user's calendar #4

Closed luscala closed 6 years ago

luscala commented 6 years ago

Hi @mattkol, I am using SugarRestSharp to pragmatically create meetings on my SuiteCRM installation. Each meeting is assigned to a defined user, but I can't see them on the calendar. I know that it's needed to place a relationship between meeting and user, via meetings_users table. How can I archieve that with SugarRestSharp?

Thanks chogori

mattkol commented 6 years ago

Sorry for the late response.

All linked relationships are achieved using custom models with Linked Modules. Please see examples @ Linked Modules 1 Linked Modules 1 Linked Modules 3

Alternatively if you know the Ids of users and meetings to join you can treat MeetingUsers as a module and save that. MeetingUsers

Please let me know if this helps.

luscala commented 6 years ago

Yes, I know ids of meeting and assigned-user that I want to link. In particular,

        Meeting meeting = new Meeting();
        // meeting information here...

        MeetingsUsers meetingUser = new MeetingsUsers();
        meetingUser .MeetingId = meeting.Id;
        meetingUser .UserId = assignedUser.Id;

        request = new SugarRestRequest("MeetingsUsers", RequestType.Create);
        request.Parameter = meetingUser;
        response = client.Execute(request);

JsonRawResponse says "Module Does Not Exist". Tryed with "meetings_users" instead of MeetingsUsers. What's wrong? Thanks

mattkol commented 6 years ago

I forgot to mention, the module must be valid "SugarCrm module" and meetings_users is not likely a valid module. Please try a call with get_available_modules (not implemented in SugarRestSharp, but done in SugarOnRest) to get list of available modules.

Meanwhile I believe you need to implement "set_relationship", which is not implemented here. SugarRestSharp only implemented these methods -get_entry, get_entry_list, set_entry, set_entries- to achieve basic CRUD operation. So I would say not currently in scope of this project. Please see Readme.

However, using what has been done here, it will be easy to extend at your end, and if you are comfortable with this I will accept a PR. These are the links from SugarCrm site: set_relationship -and- set_relationships

You can try modify InsertEntry for that.

If I need to make change to add this feature, I can do it weekend. Please let me know if you need more info before then. Thanks.

luscala commented 6 years ago

Ok, done with a new InsertRelationship class (with InsertRelatioshipResponse, new RequestType...). It works, but there's a problem when deleting (but it seems to be a permission problem). I don't know how git works, but if you want I can submit my changes.

mattkol commented 6 years ago

Thanks. That is great. You can fork and submit PR but if you want you can post entire code here. I will merge over the weekend. Thanks for your help and contribution to the project.