SugarCRM Rest API: Required fields for a Meeting entry? - sugarcrm

I'm trying to create a Meeting entry via the API, but I can't seem to find it in my calendar even though it saved successfully (I got the ID back) and I can see it in the Meetings list.
What fields do I need to populate for it to show in my Sugar calendar? Here are the fields I'm populating:
{
'assigned_user_id': '1', # My user's ID
'date_end': '2013-04-16 01:30:00',
'date_start': '2013-04-16 01:23:45',
'description': 'hello world',
'location': 'JCenter',
'name': 'Test',
'team_id': '1',
'type': 'Sugar' # This doesn't seem to be required
}

Try to set "user_id" and take a look into mettings_users table where you will find it.

Related

Drupal 8-9 REST translations

I can't send PATCH request to my REST API to send node with translations.
The error is 422 Unprocessable Entity: validation failed. title: Title: this field cannot hold more than 1 values.
I was trying JSON:API and REST, but the only way I found is to manually create translations, and after that update each translation separately.
The data I'm trying to PATCH to REST is
const data = {
'type': 'charset',
'title': [
{ 'value': sName1, 'lang': 'en' },
{ 'value': sName2, 'lang': 'ru' },
],
'field_unicode_range': [{ 'from': iFrom, 'to': iTo }],
};
The JSON:API does not seem to currently support translations (Nov 2021).
"does support PATCH requests on translations: updating translations is possible" source.
There does seem to be some work going on around this is this issue

How to get latest bot response in rasa Chatbot?

How to get latest bot response with Rasa Chatbot?
For getting user input we use : tracker.latest_message['text']
So, what is syntax for getting latest bot response ?
Thanks
You can use the tracker.events list to fetch the latest bot event.
bot_event = next(e for e in reversed(tracker.events) if e["event"] == "bot")
This will go through the reversed list of events (making it from latest to oldest) and pick the first bot event using the next() function.
The event will be have the following format:
{'event': 'bot', 'timestamp': 1601789469.174273, 'text': 'Hey! How are you?', 'data': {'elements': None, 'quick_replies': None, 'buttons': None, 'attachment': None, 'image': None, 'custom': None}, 'metadata': {}}
There you can simply take the 'text' param if you are only interested in the message.

Correct way to do a PATCH upsert request

What is the proper way to request the following upsert to a REST API?
I'm struggling to structure a NoSQL collection, which is based on the most requested returns to the front-end application.
Suppose you have the following document:
{
'user' : {
'private_comments': [
//object available only to user 1
{
'id': 1,
'bar': 'He is very good',
'...': '...'
},
//object available only to user 2
{
'id': 2,
'bar': 'He is very bad',
'...': '...'
}
],
'public_comments': '' //infos available to all users
}
}
It is needed to upsert an element to the user.private_comments array.
According to https://www.rfc-editor.org/rfc/rfc6902#appendix-A.5, I could request a replace instruction PATCHing the following data:
{ 'op': 'replace', 'path': '/user/comments/$index', 'value': 'Actually, he is OK'}
The problem is that '$index' is unknown in this case.
A possible solution that I came up with was to create something like the following operation:
{ 'op': 'upsert', 'find_by': 'id', 'find': 1, 'path': '/user/comments', 'value': 'Nope, he really sucks' }
However, the user implementing the API should't provide the id value inside the PATCH request, because this value is already accessible via the receive token. Should I simplify the operation to:
{ 'op': 'upsert', 'path': '/user/comments', 'value': 'Nope, he really sucks' }
and treat it at the backend, so when it's and upsert operation without 'find' and 'find_by' variables I assume 'find_by': 'id' and 'find': value_from_token?
Also, I cannot do a simple GET/UPDATE at the hole document because the user doesn't receive the hole document, so an update would compromise the data.

Is it possible to create indexes in Mongodb for dynamic fields?

My site has several "domains" which represent sub-sections of the site. Each "domain" has its own users with profiles, and a search page where you can search for users based on profile fields that the users fill out.
User data from the 'users' collection is structured like so:
{
username: 'shawnmichaels',
first_name: 'Shawn',
last_name: 'Michaels',
domains: [
{
name: 'domain1',
user_fields: {
'bio': 'Short bio related to domain 1',
'skills': 'Pertinent skills for domain 1'
}
},
{
name: 'domain2',
user_fields: {
'bio': 'Short bio related to domain 2',
'skills': 'Pertinent skills for domain 2'
}
}
]
}
So, users have field data across multiple domains. The domain names and field names are dynamic. There could potentially be hundreds of domains for a user and dozens of fields in a domain.
Is it possible to have some sort of dynamic index so that I can search for fields under 'domain1' without getting any matches in 'domain2'?
For example, if a user1 has "skills": ["karate", "judo"] under 'domain1', and I want to search domain2 for "karate", I don't want a match for user1.
For anyone interested, I've answered my own question after a day of research.
I'm pretty new to MongoDB and didn't realize you can query arrays by treating them like any other keys, like so:
db.users.find({domains.title: 'domain1'})
// where 'domains' is an array of object each with a 'title' key
With this knowledge, I added a text index for each field I want to be searchable:
db.users.ensureIndex({
'username': 'text',
'first_name': 'text',
'last_name': 'text',
'domains.fields.bio': 'text',
'domains.fields.skills': 'text',
'domains.fields.title': 'text',
'domains.fields.training': 'text'
}, {name: 'domain_search'})
And I structured search queries in each domain like so:
db.users.find({
'domains.title': DOMAIN_NAME,
'$text': {'$search': SEARCH_TERM}
})

Client-side validation with Facebook Registration XFBML

I'm using XFBML embedded in a HTML5 document. I've set up client-side validation following the instructions provided in the "Registration Advanced Uses" doc on Facebook's site, but it only shows errors on blur, and doesn't validate when I click the "Register" button (so if I fill out a field wrong and click outside on another element, it displays the error, but then I can click on the Register button and it registers me anyway).
I've traced it in the JS debugger, and by adding alert/log statements, and my validate_registration function only gets called onblur, and never when I click the Register button.
Anyone seen this behavior and know what I'm missing here? The live example Facebook has on the "Registration Advanced Uses" works perfectly, so I know I've got a mistake somewhere.
My XFBML tag is this:
<div class="fb-registration"
onvalidate="validate_registration"
fields="[
{'name': 'name'},
{'name': 'first_name'},
{'name': 'gender'},
{'name': 'email'},
{'name': 'user_type', 'description': 'Are you a?', 'type': 'select',
'options': {
'parent': 'Parent/Guardian looking for childcare',
'sitter': 'Babysitter/Nanny looking for sitting jobs'
}
},
{'name': 'zip_code', 'description': 'Zip code', 'type': 'text'},
{'name': 'over_eighteen', 'description': 'I am at least 18 years old', 'type': 'checkbox' }
]"
fb_only="true"
redirect-uri="<%= parse_fb_connect_signed_request_users_url %>"
width="530">
</div>
and my validation function is this:
function validate_registration (custom_fields) {
var errors = {},
regexZipCode = /^\d\d\d\d\d$/;
console.log("in validate_registration");
if (custom_fields.user_type !== 'parent' && custom_fields.user_type !== 'sitter') {
errors.user_type = "Select either Parent or Sitter";
}
if ( ! regexZipCode.test(custom_fields.zip_code) ) {
errors.zip_code = 'Enter your 5-digit U.S. zip code';
}
if ( ! custom_fields.over_eighteen ) {
errors.over_eighteen = 'You must be at least 18 years old to use this site!';
}
return errors;
}
So, never mind this.
I was getting the message "You've just registered for X using your Facebook account.
If you didn't mean to do this, you can undo this below." and thought that it meant I had registered. But if I click "Continue" at that point, it shows me all the validation errors, so it does work correctly - it just doesn't validate until after the final step.