3

Has anyone used mobileAddContact on ios and managed to add an address?

So far I can add the name, contact details (phone, email etc) but I can't add the address details (Street, City, Zip, etc.).

This is the code I've written;

 mobileAddContact \
     "firstname", tFirstName, \
     "middlename", tMiddleName, \
     "lastname", tLastName, \
     "prefix", tPrefix, \
     "organization", tOrganisation, \
     "emailhome", tEmailHome, \
     "phonemobile", tPhoneMobile, \
     "phonehome", tPhoneHome, \
     "phonework", tPhoneWork, \
     "note", tNote, \
     "addressstreethome", "Street Name", \
     "addresscityhome", "City Name", \
     "addressstatehome", "State Name", \
     "addressziphome", "Postcode", \
     "addresscountryhome", "Country"

Any help would be appreciated.

TIA, AA.

3 Answers3

0

First of all, it looks like you ran into a bug which needs to be reported to RunRev. I checked your example and the syntax in the documentation and there is nothing in your script that shouldn't work.

Second, you could try a few things, such as splitting up the command into one to create the contact and one to update the contact with the address information. You might also try putting all the info, including the address information, into variables. It seems that in your example the pairs containing variables work but the pairs that contain strings don't.

Third, I wonder if there is a maximum amount of data that can be stored in the address book. Perhaps the data in tNote is too long. I should stress that I'm not sure whether the latter matters.

Mark
  • 2,380
  • 11
  • 29
  • 49
  • Hi Mark, thank you for taking the time to respond. In my original code all the info was in variables, so I tried to use strings to double check that the variables weren't to blame. The data in tNote is about 100 chars. But I will try leaving it out for now. I also did consider splitting the command, but I can't see how update works as I can't use a contact key in the command mobileUpdateContact (or I might be missing something...) – Alex Alexander Apr 07 '13 at 21:37
  • Further update... Changing tNote made no difference. I split the command, saved the key and used mobileUpdateContact. This brought up a screen to select an existing contact or add a new one, so I selected existing. There was no address added either... I submitted a report to Livecode. Fingers crossed... – Alex Alexander Apr 07 '13 at 22:05
  • mobileAddContact should return a number if the contact is created. This is the ID number of the new contact. You can use mobileUpdateContact to update the contact. I know this isn't the right solution, but it would be useful to test this and see if it works. If mobileUpdateContact works but mobileAddContact doesn't, then it is definitely a bug that needs to be reported. – Mark Apr 08 '13 at 09:42
  • Mark, I have captured the contact ID from mobileAddContact however, mobileUpdateContact does not accept an ID unless I missed something in the dictionary. mobileCreateContact brings up an interactive dialog that lets you put in all the details. I don't want to use it because it defeats the purpose of exporting the data in the background. – Alex Alexander Apr 09 '13 at 04:26
  • I have just been attempting to use mobileUpdateContact, too. As Alex points out, there is no provision in the syntax of mobileUpdateContact to include an ID. If you have an existing contact named, for example, "John Smith", and you select this in the iOS interface, it does not append the data to the "John Smith" entry. If instead you "Create New" via the interface, it makes a duplicate entry in the Contacts... and leaves you no way to escape the displayed interface, except pressing the hardware Home button. Very confusing! – Charles B Jul 30 '14 at 02:33
0

Unfortunately you've uncovered a bug in the documentation. This area of the mobile functionality was improved in LiveCode 5.5.1 and included a syntax change, but did not result in an update to the documentation.

The mobileContact commands all require a nested array of data which is used to create/update contact information. The dictionary entries are all being updated and will be in LiveCode 6.0. In the mean time, take a look at page 48 of the iOS release notes which details the exact usage and format of these commands.

local tContactData

put "John" into tContactData["firstname"]
put "Smith" into tContactData["lastname"]
put "+44(0)77774443555" into tContactData["phone"]["mobile"][1]

mobileCreateContact tContactData
Benjamin Beaumont
  • 910
  • 1
  • 6
  • 14
  • Thanks Benjamin. I assume you are referring to the 6.0 iOS release notes. Where can I find them? – Alex Alexander Apr 08 '13 at 14:30
  • http://www.runrev.com/downloads/livecode/5_5_4/LiveCodeNotes-5_5_4-iOS.pdf - Pages 44-48 – Benjamin Beaumont Apr 08 '13 at 15:00
  • Benjamin, I don´t see a mention of arrays in that document. Are you sure this is the correct file? – Mark Apr 08 '13 at 19:34
  • I tried Benjamin's suggestion with mobileAddContact but that doesn't seem to work either. I took a stab at the address details eg ["address"]["street"]["home"][1] but now the contact gets created without any details (no name!). When I tried mobileCreateContact it brought up an interactive dialog with all fields blank. – Alex Alexander Apr 09 '13 at 04:29
  • put item 1 of tNameDetails into tContactData["prefix"] put item 2 of tNameDetails into tContactData["firstname"] put item 1 of tNameDetails2 into tContactData["address"]["home"][1]["street"] put item 2 of tNameDetails2 into tContactData["address"]["home"][1]["city"] put item 3 of tNameDetails2 into tContactData["address"]["home"][1]["state"] put item 4 of tNameDetails2 into tContactData["address"]["home"][1]["zip"] put item 5 of tNameDetails2 into tContactData["address"]["home"][1]["country"] mobileAddContact tContactData – Alex Alexander Apr 09 '13 at 13:56
0

I just tested the code you posted but replaced your variables with strings. I created a blank stack with a button and field and put the following code into the button:

on mouseUp
   put "mr" into tContactData["prefix"] 
   put "ben" into tContactData["firstname"] 
   put "street" into tContactData["address"]["home"][1]["street"] 
   put "city"  into tContactData["address"]["home"][1]["city"] 
   put "state" into tContactData["address"]["home"][1]["state"] 
   put "zip" into tContactData["address"]["home"][1]["zip"] 
   put "country" into tContactData["address"]["home"][1]["country"] 

   mobileAddContact tContactData
   put the result into field 1
end mouseUp

You'll notice from the dictionary that it puts the numeric ID of the contact into 'the result' if successful. In my case my iOS simulator had no contacts so I got '1' and when I went to my contacts I had one entry.. 'mr ben'.

I hope that helps.

Benjamin Beaumont
  • 910
  • 1
  • 6
  • 14
  • Ben, I copied your code and ran it on both the iPad and the simulator using 5.5.4. In both instances a record was created as 'No Name" with no data whatsoever. I can't test it with 6.0 because I can't create a standalone. I've posted another question about that today! – Alex Alexander Apr 11 '13 at 12:23