How to creating Accounts and Contacts programatically? - vtiger

I want to create an Account programmatically and then create a number of Contacts programmatically and associate them with the Account.
We have a number of vTiger instances that run on the same server and I am building a custom manager to add Accounts and Contacts to targeted vTiger instances.
In the custom manager the workflow is a user can select the target vTiger instance from a select menu, this action fills out some details in the custom manager form. On submitting this form the system navigates to the targeted vTiger instance and creates the account and contact.
I had a look at the Webservice tutorial but with our infrastructure we would prefer to avoid HTTP. I can (folder) navigate to a vTiger instance and invoke a class. I can then pass an array to that class to create the Account or Contact. This way we are reducing security risks by using HTTP and everything is internal.
Could anyone point me in the right direction?

To create an Account you can create a function will contains this:
(You must include all mandatories fields)
global $current_user;
include_once 'modules/Accounts/Accounts.php';
$my_account = new Accounts();
$my_account->column_fields['accountname'] = $accountName;
$my_account->column_fields['accounttype'] = $accountType;
$my_account->column_fields['email1'] = $email;
$my_account->column_fields['assigned_user_id'] = $current_user->id;
$my_account->save('Accounts');
To update an existing Account:
$moduleName = 'Accounts';
$recordModel= Vtiger_Record_Model::getInstanceById($accountId,$moduleName);
$recordModel->set('accountname', $myNewAccountName);
$recordModel->set('mode', 'edit');
$recordModel->save();

Related

Is there a way to use custom attributes for Amazon Cognito using the Hosted UI?

I'm trying to use the Hosted UI feature with AWS Cognito's User Pool to create a login / signup form for a web application.
I can select certain "standard attributes" for user registration, and those show up on the Hosted UI. For example these attributes...
Show up like this on the Hosted UI...
But if I were to add some custom attributes...
Nothing changes, and the Signup fields and form look exactly like they do in the middle picture. They are basically hidden attributes to that UI.
Is there any way to make those custom fields populate so that a user can fill them in?
Furthermore... These custom attributes don't even show up in the user's information from my User Pool 'Users and groups' area. As you can see, the only attributes showing up are those 'standard attributes'. The custom ones are nowhere to be found.
AWS says that at this moment, unfortunately, it is not possible to show the custom attributes on the Cognito hosted UI sign-up page. Also, the custom attributes cannot be marked as “required”.
As for the second Question. Custom attributes will not be reflected in the Users/Groups area until they are added to the user, which, again, cannot be done through the Hosted UI.

G Suite: add users in child Organizational unit to Group automatically

When I add a new user to a child OU, how can I also add this user to the corresponding group automatically?
My scenario is that I have a Teachers child OU, when I add a new teacher, I also want to add the new teacher to the all_teachers group, so that:
we can send email to all_teachers.
all_teachers group is in the "classroom_teachers" group so that they can create a classroom.
What's the best way to achieve this? Thanks.
On a high level, you could do the following:
Fetch the users of the OU via the Admin Directory service.
Fetch the members of the group.
Compare the two and create an array of users' email address to be added.
Add the members to the group via the Admin Directory service.
There are some script samples that will help you get started at the Apps Script Reference's page on the Admin Directory advanced service.

How do I create a Team Leader/Group Leader in Django?

I'm new(this is my first project) to web development. I'm creating an internal data management for the company i work for. We have different departments(like r&d, product development, etc) which I have instantiated as objects via Django admin. I have created employees as normal Users in django admin. I would like to know how I can create a model/anything which can tell me the department manager.
Django auth user has reference to the group model. So you can create a group called Teamleader in group table(django admin) and while creating a user link the user to the group desired for his role

Adding and changing User and Roles to Sitecore domain through API

I have to create a separate web project to access the Roles and Users API for sitecore domain, so I can programmatically add new Roles with custom access to the tree as well as custom language access. I have found the documentation for Security API, http://sdn.sitecore.net/upload/sitecore6/sc61keywords/security_api_cookbook_usletter.pdf
But I am not sure how to go about adding a new role, can I just create any type of project, like MVC4 or does it have to be in WebForms? Is this even possible to add custom permission to the tree by adding new roles and assigning them new users through API, so they can just login normally through the SiteCore domain? Also, what database am I supposed to use, I see there are 3 different ones (core,master,web), do I have to manually connect to the database and add roles there, or the API's will do that for me?
I ended up creating a class that lets me add new languages(regions) when needed. Here is the idea I worked with.
using(new Sitecore.Security.Accounts.UserSwitcher(user) //To switch to any user you want, in my case it was the "sitecore/admin"
System.Web.Security.Roles.CreateRole(roleName) //To create roles
var role = Sitecore.Security.Accounts.Role.FromName(roleName) //To retrieve the role.
//Get a list of the permissions that you would like to set
//For every item in that list
AccessRuleCollection accessRule = Item.Security.GetAccessRules();
acessRule.Helper.AddAccessPermission(role,AccessRight,PropagationType,AccessPermission);
//Write the Rules back to the item
Item.Editing.BeginEdit();
Item.Security.SetAccessRules(accessRules);
Item.Editing.EndEdit();
Hope that helps.

Create a Magento admin user using the API

I want to create an admin user for a Magento store using the web services and not having to create it from the adminstrators web site. Is that possible??
Thanks in advance!
Check out this project: https://github.com/nvahalik/Wiz.
Wiz lets you do many cumbersome tasks (normally done in the Magento Admin Panel) from command line. Although it isn't a webservice, it allows you to skip the need of logging into the admin panel and clicking around.
BTW, one of these tasks is creating an admin user.
One approach that takes a bit of custom coding is to create a new API resource that can use the Mage::getModel('admin/user') model to create the admin user.
I found it, since I was trying to do all that in C#, here is the simple code to do that:
MagentoService proxy = new MagentoService();
string sessionId = proxy.login(username, password);
customerCustomerEntityToCreate ctc = new customerCustomerEntityToCreate();
ctc.email = email;
ctc.firstname = firstname;
ctc.lastname = lastname;
ctc.password = password;
proxy.customerCustomerCreate(sessionId, ctc);
First Step
Bind the new user to a predefined role. A role for the API must be created in System → Web Services → Roles before it can be assigned here.
Source
Second Step
Use SOAP v1/v2 or XML-RPC (in my case it's SOAP v1)
Here's the
Tutorial link. You can manage customer till manage order.
Hope this help.