Can't edit customers informations in OTRS agent backend

English! place to talk about development, programming and coding
Post Reply
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

Can't edit customers informations in OTRS agent backend

Post by benoitm »

EDIT : GO to my last post, modified question

Hi,

Another post for another problem, I think this one is not so hard but I don't find any solution in others topics.
I'm programming PHP API for OTRS. So I'm my customers will be able to create a new ticket trought php.

But before creating the first customer ticket, I need to clone customer informations from my database website.
So after verifying the customer is not "know" by OTRS (done with php / mysql with the customer_user table (id)), I'm creating new entry with SOAP and php, here is my code : (from a homemade php class)

Code: Select all

	public function create_otrs_user(){
		global $c_infos;
		global $c_address;
		$pays = "France";
		$rdmNumber = rand(1, 9999);
		$rdmLogin = "utilisateur_".$rdmNumber;
		
		// Vérif que le login insérer dans la bdd otrs est unique 
		function isUniqueLogin($rdmLogin){
			$check_rdm = mysql_query("SELECT login FROM customer_user WHERE login='".$rdmLogin."'");
			if (!tep_db_num_rows($check_rdm)) return true;
			else return false;
		}
		
		while(!isUniqueLogin($rdmLogin)){
			$rdmNumber +=1;
			$rdmLogin = "utilisateur_".$rdmNumber;
		}
		/* ---------- */
	
		$otrs_user_login = $this->soapclient->__soapCall("Dispatch", array($this->user, $this->pass,
			"CustomerUserObject", "CustomerUserAdd",
			"Source",    'CustomerUser', # CustomerUser source config
			"UserFirstname", utf8_encode($c_infos['customers_firstname']),
			"UserLastname",  utf8_encode($c_infos['customers_lastname']),
			"UserCustomerID",  utf8_encode($c_infos['customers_id']),
			"UserLogin",  	utf8_encode($rdmLogin),
			"UserEmail",  	utf8_encode($c_infos['customers_email_address']),
			"UserPhone", 	utf8_encode($c_infos['customers_telephone']),
			"UserFax",		utf8_encode($c_infos['customers_fax']),
			"UserMobile",	utf8_encode($c_infos['customers_telephone']),
			"UserStreet",  	utf8_encode($c_address['entry_street_adress']),
			"UserZip", 		utf8_encode($c_address['entry_postcode']),
			"UserCity",  	utf8_encode($c_address['entry_city']),
			"UserCountry",  utf8_encode($pays),
			"ValidID", 1,
			"UserID", 1,
			));	
	}
All is ok, no OTRS log error, and the data are injected in the OTRS database, all ok BUT when I'm in this customer ticket zoom view, there is "no informations available" in the right column. For more, when I go to "customer" section in OTRS, (editing the customer) no informations, field are blank !

I need to get customers informations In OTRS, for my agents.

What is the probleme here? Thanks a lot (please move topic if needed)
Last edited by benoitm on 08 Apr 2011, 14:28, edited 2 times in total.
Daniel Obee
Moderator
Posts: 644
Joined: 19 Jun 2007, 17:11
Znuny Version: various
Real Name: Daniel Obée
Location: Berlin

Re: Can't get customer informations in OTRS agent backend

Post by Daniel Obee »

You will need a userID.

Greets
Dan
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

Re: Can't get customer informations in OTRS agent backend

Post by benoitm »

EDIT : the customer informations are not available only when it's a php SOAP created ticket.

(when I create a phone ticket in OTRS, informations are shown)

here is the code used to create the new ticket, php :

Code: Select all

		try{
					$numeroTicket = $this->soapclient->__soapCall("Dispatch", array($this->user, $this->pass, "TicketObject", "TicketCreateNumber"));
					if(! is_string($numeroTicket) ) $numeroTicket = number_format($numeroTicket,0, '.', '');
					
					$this->idTicket = $this->soapclient->__soapCall("Dispatch", array($this->user, $this->pass, 
						"TicketObject", "TicketCreate",
						"TN", 			$numeroTicket, 
						"Title", 		"[ Ticket#: ".$numeroTicket." ] ".$title,
						"Queue",        "Test", 
						"Lock",         "Unlock", 
						"PriorityID",   3, 
						"State",        "new", 
						"CustomerID", 	utf8_encode($customer_id), 
						"CustomerUser", $from, 
						"OwnerID",      1, 
						"UserID",       1,
					));
					
					PhpSoap::create_article($this->idTicket, $customer_id, $customer_message);				
				}
				catch(SoapFault $soap_error){
					$error = true;
					$this->soap_error = $soap_error;
					echo "<hr/>".$soap_error."<hr/>";
				}
			}
	

	

@ tisar : I give "1" to userID, for all new ticket, because I have not found what "userID" is really :: Is it an error ?
Last edited by benoitm on 06 Apr 2011, 12:29, edited 2 times in total.
Daniel Obee
Moderator
Posts: 644
Joined: 19 Jun 2007, 17:11
Znuny Version: various
Real Name: Daniel Obée
Location: Berlin

Re: Can't get customer informations in OTRS agent backend

Post by Daniel Obee »

Sorry. Mixed up something here.

Seems the CustomerID is not set properly in the ticket create process. Actually I cannot see how you create the ticket - so I reckon the mistake must lie in there. Also it seems you create the customer including the unique ID. How do you know the ID while creating them?

Greets
Dan
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

Re: Can't get customer informations in OTRS agent backend

Post by benoitm »

The code used to create the ticket is up, in my last post :)

Maybe yes there is an error while creating cusutomer but what is "UserID" when i call CustomerUserAdd ?
If I let it blank, OTRS log show an error and the customer is not created

Code: Select all

[Wed Apr  6 12:26:36 2011][Error][Kernel::System::CustomerUser::DB::CustomerUserAdd][556] Need UserID!
I think UserID here is the id of the "agent" who create the user ... isn't it ? "1" is my agent id
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

Re: Can't get customer informations in OTRS agent backend

Post by benoitm »

solved ... thanks to try to help me ^^'
Daniel Obee
Moderator
Posts: 644
Joined: 19 Jun 2007, 17:11
Znuny Version: various
Real Name: Daniel Obée
Location: Berlin

Re: Can't get customer informations in OTRS agent backend

Post by Daniel Obee »

benoitm wrote:I think UserID here is the id of the "agent" who create the user ... isn't it ? "1" is my agent id
It is ;) So... what caused the error? Anything we can learn?

Greets,
Dan
benoitm
Znuny newbie
Posts: 34
Joined: 21 Mar 2011, 10:22
Znuny Version: 3.0.6

Re: [SOLVED]Can't get customer information in OTRS agent bac

Post by benoitm »

Yes you can ;)

The error was during ticket creation process : during that, we NEED to set "CustomerUser" = to "CustomerID" (with SOAP) and that's all :)

After that, informations are now available BUT there is one problem again :

When we go to "customers" in OTRS menu, I can see my customers BUT when I click on one to edit, all the field still empty, with no erros in OTRS logs...

Have you got idea ?? thanks a lot
Post Reply