Double relation in Servoy Mobile (create)

Discussions regarding developing applications using Servoy Mobile (new in Servoy 7)

Double relation in Servoy Mobile (create)

Postby vincentc » Tue Mar 05, 2013 11:02 am

Hello,

We are currently developping a Mobile application for Sage CRM thanks to Servoy Mobile. I have a question about how to retrieve a field value thanks to a double relation on a Mobile form (in the ws_create).

I give you an example.

In Sage CRM, this is the way to retrieve the telephone number of a Contact (table Person):

Person
pers_personid
(…)

Phone_Link
plink_phonelinkid
#plink_recordid (here equivalent to pers_personid)
#plink_entityid (always equivalent to the value '13' pour the entity Person)
(…)


Phone
phon_phoneid
#phon_phonelinkid
phon_number (the field that we want retrieve)
(…)


So we made 2 relations to retrieve the telephone number of a Contact:

svy_rel1.png


and

svy_rel2.png



svy_mob_form.png


With the "data" object in parameter, we are able to read the info (ws_read), as well as update (ws_update) but we are unable to retrieve the value of the phone number in the ws_create. Do you have an idea of ​​how to get it?

Thank you very much in advance.

Vincent
You do not have the required permissions to view the files attached to this post.
Last edited by vincentc on Tue Mar 05, 2013 3:14 pm, edited 1 time in total.
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Double relation in Seroy Mobile (create)

Postby jcompagner » Tue Mar 05, 2013 11:34 am

so you are saying in mobile you do create a new record, you do create a new relation (2 times) and you do fill in the phone number but that relation record you don't get in the sync to the server?
Do you have a ws_create on the table of that relation?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Double relation in Seroy Mobile (create)

Postby vincentc » Tue Mar 05, 2013 1:00 pm

I answer "yes" to your two questions.

I have a ws_create on my phonelink table and on my phone table but these methods aren't fired (I think this is because the mobile form is based on the table Person).
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Double relation in Seroy Mobile (create)

Postby jcompagner » Tue Mar 05, 2013 2:34 pm

if new record are created through the relation then those new records should be pushed
please make an example where you have a mobile solution and a service solution and make a case from that.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Double relation in Servoy Mobile (create)

Postby vincentc » Wed Mar 06, 2013 5:39 pm

Do you mean that I have to export my 2 solutions Mobile and Service (+ the war file) and send it to the support with the previous explainations ?
I currently use a SQL Server database (Sage CRM), isn't that a problem for the Servoy Support ?

Because of absence of reaction of the ws_create method of Phone and PhoneLink, I do the creation of these records manually in the ws_create of the Person table. But I can't retrieve the phone number newly created (data.person_to_phonelink.phonelink_to_phone.phon_number doesn't work)

Here is the code of the ws_create in my data_person form, maybe it will help you to understand that I want to do :


Code: Select all
function ws_create(data,version,pk)
{

   application.output(data, LOGGINGLEVEL.ERROR)
   //example of the content of the data object : {pers_firstname:Doug,modification_date:1362581796497,pers_personid:15,pers_lastname:Lasse,pers_companyid:66992,created_on_device:true}
        //Don't understand why the pers_personid is 115 ???

   
   var fsUsers = databaseManager.getFoundSet('veolia_waters','users')
   var fsCompany = databaseManager.getFoundSet('veolia_waters', 'company')
   //We load the record of the company under which we created the contact
   fsCompany.loadRecords(data.pers_companyid)
   
   fsUsers.loadRecords(globals.userid)
   
   var recCurUser = fsUsers.getSelectedRecord()
   var recCurCompany = fsCompany.getSelectedRecord()
   
   var CurPersonId = createPerson(recCurUser,data)
        (...)
   
   createPhone(recCurCompany,CurPersonId,data)                     
   
   databaseManager.saveData();
   
   foundset.loadAllRecords();

   databaseManager.saveData()
   
}


function createPerson(pRecCurUser,pData)
{
   var oldPersonId = globals.createSageCrm('Person')
   var rec = foundset.getRecord(foundset.newRecord());
   var today = new Date();
   
   rec.pers_personid = oldPersonId;
   rec.pers_firstname = pData.pers_firstname;
   rec.pers_lastname = pData.pers_lastname;
   rec.pers_companyid = pData.pers_companyid
   rec.pers_createdby = globals.userid;
   rec.pers_createddate = today;
   rec.pers_timestamp = today;
   rec.pers_channelid = pRecCurUser.user_primarychannelid
   rec.pers_secterr = pRecCurUser.user_primaryterritory
   
   return oldPersonId
}

function createPhone(pRecCurCompany,pRecCurPersonId,pData)
{
   
   if (pData.person_to_phonelink.phonellink_to_phone.phon_number) //this condition DOESN'T WORK
   {
      var today = new Date();
      var fsPhone = databaseManager.getFoundSet('veolia_waters','phone')
      var oldPhoneId = globals.createSageCrm('Phone')
      var recPhone = fsPhone.getRecord(fsPhone.newRecord());
   
      recPhone.phon_phoneid = oldPhoneId;
      recPhone.phon_countrycode = null;
      recPhone.phon_areacode = null;
           recPhone.phon_number = pData.person_to_phonelink.phonelink_to_phone.phon_number //DOESN'T WORK
      recPhone.phon_createdby = globals.userid;
      recPhone.phon_createddate = today;
      recPhone.phon_updatedby = globals.userid;
      recPhone.phon_timestamp = today;
      recPhone.phon_updateddate = today;
   }

   createPhoneLink(pRecCurCompany,pRecCurPersonId,pData,oldPhoneId)


}

function createPhoneLink(pRecCurCompany,pRecCurPersonId,pData,pRecCurPhoneId)
{
   var rec;
   var oldPhoneLinkId;
   var today = new Date();
   var fsPhoneLink = databaseManager.getFoundSet('veolia_waters','phonelink')
   var recPhoneLink;

        //If a phone number is typed in the Mobile app, create phone number for the Contact
        //Else, retrieve the phone of the contact Company

   if (pData.person_to_phonelink.phonellink_to_phone.phon_number)
   {
      oldPhoneLinkId = globals.createSageCrm('PhoneLink') //10331
      recPhoneLink = fsPhoneLink.getRecord(fsPhoneLink.newRecord());
      
      fsPhoneLink.plink_linkid = oldPhoneLinkId
      fsPhoneLink.plink_recordid = pRecCurPersonId
      fsPhoneLink.plink_entityid = 13
      fsPhoneLink.plink_phoneid = pRecCurPhoneId
      fsPhoneLink.plink_type = 'Business'
      fsPhoneLink.plink_createdby = globals.userid
      fsPhoneLink.plink_createddate = today;
      fsPhoneLink.plink_updatedby = globals.userid;
      fsPhoneLink.plink_updateddate = today;
      
      
      
   }
   else
   {

      //Search the phone number of the contact Company    
      fsPhoneLink.find()
      fsPhoneLink.plink_recordid = pRecCurCompany.comp_companyid
      fsPhoneLink.plink_entityid = 5
      fsPhoneLink.search()
      
      if (fsPhoneLink.getSize() > 0)
      {   
         rec = fsPhoneLink.getRecord(1); //fsPhoneLink.getRecord(i);

         oldPhoneLinkId = globals.createSageCrm('PhoneLink')
         recPhoneLink = fsPhoneLink.getRecord(fsPhoneLink.newRecord());
         
         fsPhoneLink.plink_linkid = oldPhoneLinkId
         fsPhoneLink.plink_recordid = pRecCurPersonId
         fsPhoneLink.plink_entityid = 13
         fsPhoneLink.plink_phoneid = rec.plink_phoneid
         fsPhoneLink.plink_type = rec.plink_type
         fsPhoneLink.plink_createdby = globals.userid
         fsPhoneLink.plink_createddate = today;
         fsPhoneLink.plink_updatedby = globals.userid;
         fsPhoneLink.plink_updateddate = today;
      }
      
   }
         
}
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am

Re: Double relation in Servoy Mobile (create)

Postby jcompagner » Wed Mar 06, 2013 6:53 pm

we just need an example of the 2 solution files, we don't need a war file, just the servoy solutions

you could export with sample data, so we can test it on any database
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: Double relation in Servoy Mobile (create)

Postby vincentc » Thu Mar 07, 2013 11:52 am

Case created (SVY-4097)

Thanks again!
vincentc
 
Posts: 56
Joined: Thu Aug 25, 2011 11:12 am


Return to Servoy Mobile

Who is online

Users browsing this forum: No registered users and 1 guest