Strategic Software Consultant

I'm the partner of choice for many of the world's leading enterprises. I help businesses elevate their value through solution discovery, software development, design, QA, and consultancy services. As your Strategic Software Consultant, I work across many technology products and delivery teams. The scope of technology is broad, and it is my job to understand how your technology applications holistically support and connect to create a sustainable technology ecosystem. The ecosystem of technologies may span to 3rd party applications, in-house developed solutions, business intelligence, data integrations, and of course, SaaS applications.

Oracle Certified Specialist
Oracle B2C Service Cloud

Oracle Service Cloud Service Staff Account Import

<?php
namespace Custom\Controllers;

use RightNow\Connect\v1_3 as Connect;

class StaffAccountImport extends \RightNow\Controllers\Base
{
    function __construct()
    {
        parent::__construct();
    }

    function accounts(){
        echo '
        <div style="width:801px;height:600px;margin:50px auto;">
        <h2>Staff Account Import</h2>
        Paste a comma separated list of staff account values with each staff account on a new line.<br><br>
        <b>Format</b>: <i>Usser Name, First Name, Last Name, Group ID, Email Address, Profile ID</i><br><br>
        Password for all accounts set to <b>Welcome!</b>.
        <form action="agentLoader" method="post">
           <textarea name="accounts" id="accounts" style="height:500px; width:800px;"></textarea><br/><br/>
           <input type="submit" value="Create Staff Accounts"/>
        </form>
        </div>
        ';
    }

    function agentLoader(){
        $data = $_POST['accounts'];
        $data = explode("\n", $data);

        try{
            foreach($data as $row){
                $fields = explode(",", $row);
                //echo '<pre>';print_r($fields);echo '</pre>';
                $account = new Connect\Account();
                $account->Attributes = new Connect\AccountOptions();
                $account->Attributes->AccountLocked = 0;
                $account->Attributes->ForcePasswordChange= 0;
                $account->Attributes->PasswordNeverExpires=1;
                $account->Attributes->PermanentlyDisabled =0;
                $account->Attributes->StaffAssignmentDisabled=1;
                $account->Attributes->ViewsReportsDisabled=1;

                $account->Login = trim($fields[0]);

                $account->Name = new Connect\PersonFullName();
                $account->Name->First = trim($fields[1]);
                $account->Name->Last = trim($fields[2]);
                $account->DisplayName = trim($fields[1]) . " " . trim($fields[2]);
                $account->NewPassword = 'Welcome!';

                $account->Profile = new Connect\NamedIDLabel();
                $account->Profile->ID = trim($fields[5]);
                $account->StaffGroup = new Connect\NamedIDOptList();
                $account->StaffGroup->ID = trim($fields[3]);

                $account->SalesSettings = new Connect\AccountSalesSettings();
                $account->SalesSettings->DefaultCurrency = new Connect\NamedIDOptList();
                $account->SalesSettings->DefaultCurrency->ID = 1;

                $account->Country = Connect\Country::fetch(1);

                $account->Emails = new Connect\EmailArray();
                $account->Emails[0] = new Connect\Email();
                $account->Emails[0]->AddressType=new Connect\NamedIDOptList();
                $account->Emails[0]->AddressType->LookupName = "Email - Primary";
                $account->Emails[0]->Address = trim($fields[4]);


                $account->EmailNotification = new Connect\NamedIDOptList();
                $account->EmailNotification->ID = 1;

                $account->save();
                echo $fields[1] . " " . $fields[2]. " (".$fields[4].") account created<br>";
            }
            echo "<br><br>DO NOT REFRESH page.";
        }
        catch (Connect\ConnectAPIError $err) {
            echo($err->getCode() . "::" . $err->getMessage());
        }
        catch (\Exception $err) {
            echo($err->getCode() . "::" . $err->getMessage());
        }
    }
}