Announcement

Collapse
No announcement yet.

Unique field error

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • eduardofendrich
    replied
    Originally posted by Exsto View Post
    Hello,
    I solved now it works fine, but when I create a lead and not when I change it.
    Can I insert the alert also in edit? If so, how can I do it?
    Thanks
    HI, how did you solve that?

    thanks

    Leave a comment:


  • Exsto
    replied
    I am using the duplicate check also for the e-mail address. Can I get a lock so I can't save the record?

    Leave a comment:


  • Exsto
    commented on 's reply
    Ok, that's why I solved it

  • Exsto
    replied
    Hello,
    I solved now it works fine, but when I create a lead and not when I change it.
    Can I insert the alert also in edit? If so, how can I do it?
    Thanks

    Leave a comment:


  • Exsto
    replied
    the Lead.php file was created here: espocrm/custom/Espo/Custom/Services

    Leave a comment:


  • Exsto
    replied
    Hi, sorry unfortunately the Google translator helps a lot but not enough. I didn't understand what you'd like to see
    Thanks

    Leave a comment:


  • theBuzzyCoder
    commented on 's reply
    Where did you place this file? give me absolute path or relative path from espocrm folder. Also Go to Administration > click on clear cache

    and retry once

  • Exsto
    replied
    Hi, this is the file
    Thanks

    PHP Code:
    namespace Espo\Custom\Services;

    use 
    Espo\ORM\Entity;

    class 
    Lead extends \Espo\Modules\Crm\Services\Lead
    {
      protected function 
    getDuplicateWhereClause(Entity $entity$data)
      {
        return array(
    'partita_iva' => $entity->get('partita_iva'));
      }

    Leave a comment:


  • theBuzzyCoder
    commented on 's reply
    Can you put the code you wrote here. The full file

  • Exsto
    replied
    Good morning,
    Can someone help me?
    Thanks

    Leave a comment:


  • Exsto
    replied
    Hello, thank you for having responded.
    I tried how you wrote, but when I try to save a lead it gives me this error:
    Errore 500: Class '\Espo\Custom\Services\Lead' does not exist.

    [2019-09-26 18:42:14] Espo.ERROR: (500) Class '\Espo\Custom\Services\Lead' does not exist.; GET /api/v1/Lead?select=salutationName%2CfirstName%2ClastName% 2Cname%2Cstatus%2CaccountName%2CemailAddressIsOpte dOut%2CemailAddress%2CemailAddressData%2CassignedU serId%2CassignedUserName%2CcreatedAt&maxSize=100&o ffset=0&orderBy=createdAt&order=desc; line: 116, file: /var/www/html/espocrm/application/Espo/Core/ServiceFactory.php

    Could you give me some suggestions?
    Thank you very much

    Leave a comment:


  • theBuzzyCoder
    replied
    Originally posted by Exsto View Post
    Thank you now it works, you have been very kind.
    There is only one problem if the field already exists from error 500, how can I display a personalized message as "VAT number already present"
    Thanks again
    Create a service in this place

    espocrm/custom/Espo/Custom/Services/<Your-Entity>.php where <your-entity> is like Lead

    PHP Code:
    namespace Espo\Custom\Services;

    use 
    Espo\ORM\Entity;

    class 
    Lead extends \Espo\Modules\Crm\Services\Lead
    {
      protected function 
    getDuplicateWhereClause(Entity $entity$data)
      {
        return array(
    'vat' => $entity->get('vat'));
      }

    Now try creating a duplicate.

    your extends <class> depends on what entity it is.

    If you check espocrm/application/Espo/Modules/Crm/Services there will be a file called Lead.php. That's why I can extend it. If you don't know what to extend with, just check espocrm/application/Espo/Modules/Crm/Services path first to see if there is a file corresponding to <your-entity>, otherwise extend below metioned class

    \Espo\Services\Record

    which points to espocrm/application/Espo/Services/Record.php file
    Last edited by theBuzzyCoder; 09-19-2019, 11:56 AM.

    Leave a comment:


  • eymen.elkum
    commented on 's reply
    he means the error message that appears when you try to save new entity with an already exist unique field value, catching the error and make it friendly

  • theBuzzyCoder
    commented on 's reply
    Your question is unclear. Are you asking for a duplicate check of field values? Can you elaborate your question with screenshots if possible

  • Exsto
    replied
    Thank you now it works, you have been very kind.
    There is only one problem, if the field already exists from error 500, how can I display a personalized message as "VAT number already present"
    Thanks again

    Leave a comment:

Working...
X