Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Custom relate to Field

  1. #1
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Custom relate to Field

    Hi,

    I created a custom relate to Field for the Contacts module. It is related to the Contacts module. I want a user to be able to select a Spouse/Partner.

    In hte DB it create fdc_sp_c and contacts_id_c.

    I went into Contact A and selected Contact B as the Spouse/Partner. In hte DB row of contacts_cstm for Contact A the fdc_sp_c is NULL and the contacts_id_c has the id of the Spouse.Partner. Why is it using the two fields and will the fdc_sp_c always be NULL?

    Next quiestion. What is the best way to make it so that when A select B that in the B detail View A will automatically appear in the Spouse/Partner relate to. I was think a logic hook would be the best approach.

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  2. #2
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Custom relate to Field

    A save logic hook sounds like your best bet. When it's saved and that field is set then you can go ahead and set that field for the Spouse's contact record as well.

  3. #3
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Custom relate to Field

    So I have this done.

    My users can now select another Client as a Spouse/Partner of a Client and both Clients are related to each other. If the relationship is cleared in one Client then it is also cleared in the other Client.

    My only problem now is if a user goes to Client A and select Client B as a Spouse/Partner but Client B already has a Spouse Partner Client C - how can I have a popup appear telling the user that the selected Client already has a Spouse/Partner showing the name etc... Then ask them to cancel or continue. With Continue the new relationship is created with Cancel the old relationship is left as it is.


    Rgds
    Chirs
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  4. #4
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Custom relate to Field

    Lots of spouse swapping over there?

    Personally, I'd assume that the info you most recently received is the latest and greatest and to just overwrite the existing spouse no matter what. On save though you could check for any contacts that also have the newly select spouse and clear their relationship so that the data is up to date.

    If you want to make it that complex you could add some ajax to the editviewdefs.php in the javascript array to make a call back and to check for any conflicts. This could get tricky and may be overkill though.

  5. #5
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Custom relate to Field

    I've pretty much got it sorted now - I'm not going to create the popup.. But I will want to remove the relationship if it is remove on one side. How do I set a field to (NULL) do I just passed the characters (NULL) or is it different

    RgdsChirs
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  6. #6
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Custom relate to Field

    Passing null should do the trick just fine.

  7. #7
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Custom relate to Field

    Hi,

    So this is want I am doing and Its not working I am getting an empty view when I press the Clear button nad then save. THis is the query I am using.

    PHP Code:
    $query "UPDATE contacts_cstm SET contacts_cstm.contact_id_c = "NULL" ";
    $query .="WHERE contacts_cstm.contact_id_c = '$contact_id'";
    $bean->db->query($query,true); 
    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  8. #8
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Custom relate to Field

    Try this instead:

    PHP Code:
    $query "UPDATE contacts_cstm SET contacts_cstm.contact_id_c = NULL ";
    $query .="WHERE contacts_cstm.contact_id_c = '$contact_id'";
    $bean->db->query($query,true); 

  9. #9
    chrislynch8's Avatar
    chrislynch8 is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    Cork, Ireland
    Posts
    747

    Default Re: Custom relate to Field

    Quote Originally Posted by eggsurplus View Post
    If you want to make it that complex you could add some ajax to the editviewdefs.php in the javascript array to make a call back and to check for any conflicts. This could get tricky and may be overkill though.
    Hi,

    I still need to do something similar to this, all I need i to have a popup appear with a message all the user then has to do is press OK, I do not need to run any extra complex code etc...

    Do I need to still do this via editviewdefs.php or can the simply popup with OK be done in the Logic Hook

    Rgds
    Chris
    Linkedin Profile:Chris Lynch

    FDC IT Solutions
    FDC House
    Wellington Road
    Cork
    Ireland

  10. #10
    eggsurplus's Avatar
    eggsurplus is offline Sugar Community Member
    Join Date
    Dec 2005
    Location
    Minnesota
    Posts
    2,343

    Default Re: Custom relate to Field

    I haven't tried it but creating a simple notification popup in an after_save logic hook should work just fine. Another alternative would be sending an email when a conflict arises if the popup piece doesn't work out.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. relate field with custom module
    By cooky in forum Developer Help
    Replies: 6
    Last Post: 2008-09-30, 05:51 AM
  2. custom relate field
    By cheku0228 in forum Developer Help
    Replies: 2
    Last Post: 2008-08-22, 09:38 AM
  3. custom module and relate field
    By thancock in forum Help
    Replies: 5
    Last Post: 2008-08-19, 04:40 PM
  4. Custom Relate field bug fixed
    By kidpollo in forum Help
    Replies: 2
    Last Post: 2007-04-04, 11:48 PM
  5. custom module custom field relate type error
    By kidpollo in forum General Discussion
    Replies: 0
    Last Post: 2007-03-24, 02:14 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •