Learning EspoCRM and Design

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • esforim
    replied
    Learning string\replace; for reference see this thread: https://forum.espocrm.com/forum/gene...ula-replace-v6

    Surprisingly, maybe it just me but the example code I was having great difficult with and have to open a thread with back and forward question to figure it out.

    Using the example code both item and Maximus based on that code and provide example, which work but not as intended to be, as everything is fixed with that code. It can be use for other purpose and that "array" style will be useful in the future to make complex replacement but right now I just need a simple change "Hello" to "World".

    Following item linkage it is quite useless to help learn a bit on how it work: https://www.php.net/manual/en/function.str-replace.php

    The issue is that these "$" won't work for EspoCRM formula, secondly the order of the formula is different. However, the documents say we can use $, maybe I'm just using it wrong: see https://docs.espocrm.com/administration/formula/#syntax

    And I believe there is also difference in using " and ' too. For PHP it is:

    search, replace, subject (string)

    Example: string\replace("Hello", "World", name)

    Whereas EspoCRM:

    string (subject), search, replace

    Example: string\replace(name, 'Hello', 'World')

    Search and replace is quite obvious, but the string/subject is where it confused me at most. I eventually tried the formula:

    name = string\replace({description}, 'Hello', 'World');

    Then
    name = string\replace(description, 'Hello', 'World');

    And to my surprise it worked, my name field copy all my description information but it change all "Hello" to "World". Thinking that it not possible to use 'name' instead of description because it will do a infinity loop:

    name = string\replace(name, 'Hello', 'World');

    But surprisingly it worked!

    To break down the formula (final) above:

    For the field name "name", I want to replace a word (string\replace), the word I want to search for is "Hello", find these "Hello" for me and replace it with "World"

    Also please note that it is Case Sensitive, "Hello" will only work for "Hello", it won't work if you write "hello". We need to use regular expression (regex) for this. Which will be another learning but I think there is plenty of tutorial out there for regex.
    Last edited by esforim; 01-14-2021, 06:15 AM.

    Leave a comment:


  • esforim
    commented on 's reply
    It look like the code also work for PDF attachment however it have 2 issue (probably because the "Helper" doesn't support it).

    (1) Quality and resolution it terrible, very ugly, and whitespace area is converted to black. It pretty much ugly.
    (2) It only do the last page (?), a PDF attachment I test got 3 pages, but it only print the 3rd page.

  • esforim
    replied
    Too Long Didn't Read - Use this PDF Template code to print Email's Attachment (image only):
    Code:
    {{#each attachmentsIds}} {{imageTag ./this}} {{/each}}
    ---

    Hi everyone,

    More learning today. I got an email that is basically asking me to do a print out of it, more specifically the attachment image, I can just use Ctrl+P (Print) using my webbrowser but sometime it look ugly, and it got data I don't have in printing (URL detail, date and time of printing, page numbers and total, etc). My second option is to save the image individual, open it and print individually.

    I usually use the "Print-to-PDF" system of it, unfortunately it quite difficult to print the attachment and it is not straight forward in term of using the formula. It not difficult though but took experimenting to do. Eventually I came up with the code above to do Attachment printing (image only), I haven't tested how it will behave to other file such as .pdf, .docx, etc.

    But otherwise it look good. Here is the code sample I did my testing with over time until found one that worked. In total there is 3 working formula, the important part is the #each and the ./this is where the magic is.

    Code below is for learning only. Number 3, 8, 9 is working. The code in TL_DR (too long didn't read) used number 9 full page page printing.

    Code:
    attachmentsEmailId {{attachmentsEmailId}}
    
    attachmentsIds {{attachmentsIds}}
    
    attachmentsNames {{attachmentsNames}}
    
    attachmentsEmailNames {{attachmentsEmailNames}}
    
    {{#each attachmentsEmailNames}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}} {{/each}}
    
    {{#each attachmentsNames}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}} {{/each}}
    
    4
    
    
    {{#each attachmentsEmailId}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}} {{/each}}
    
    3 - working
    
    
    {{#each attachmentsIds}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}} {{/each}}
    
    5
    
    
    {{#each attachmentsIds}} {{/each}}
    
    6
    
    {{#each attachmentsIds}} {{imageTag attachmentsIds width=50 height=50}} {{/each}}
    
    7
    
    {{#each attachmentsIds}} {{attachmentsIds}} {{/each}}
    
    8
    
    
    {{#each attachmentsIds}} {{imageTag attachmentsIds}} {{/each}}
    
    9 - work
    
    
    {{#each attachmentsIds}} {{imageTag ./this}} {{/each}}
    
    8 - work
    
    
    {{#each attachmentsIds}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag ./this}} {{/each}}
    
    1
    
    
    {{#each imagesIds}} {{#ifMultipleOf @key 4}}
    {{/ifMultipleOf}}{{imageTag width=150 height=150 ./this}} {{/each}}
    
    
    
    
    2
    
    
    {{imageTag attachmentsEmailIds width=50 height=50}}
    
    {{imageTag attachmentsIds width=50 height=50}}

    Leave a comment:


  • esforim
    commented on 's reply
    Yes, it just too much work to get a SF demo version (have to contact them and it is very limited time frame). They don't have "open" demo; for example: demo.espocrm.com/
    where we can just do test. From SF marketing campaign they got some niffy feature I would like to see to get innovation from but too much hassle to get a hand on their demo.

    Hope you manage to get it to work, I'm still playing with Webhook at the moment.

  • crmclients
    replied
    Thanks so much for this write up. My client has asked if Espo can send the data from the Attendance module I created to Salesforce (they are still holding on to SFDC for lead capture and gateway payment).

    They want to use the days logged to calculate employee pay which the were doing in SF with bar codes. Espo is simpler on the one hand (no more paper, printing, scanning) but the lost a process on the other.

    I might explore this with my Trailblazer SF account; maybe it can be done although I would prefer eliminate all need to have SF
    Last edited by crmclients; 01-09-2021, 08:40 PM.

    Leave a comment:


  • esforim
    replied
    Hi guys, I finally delved into the Webhooks feature of EspoCRM.

    In my way to simple explain Webhooks is basically, "Send EspoCRM Data to another website". In term using this feature I haven't figure out what to use it for yet. Maybe I can use it to write an article in EspoCRM and it get post into my Wordpress Blog.

    Anyway I'm still trying to figure it out here is some learning for any one is who interested:
    ---
    Since I already create my API user I don't need to do it again: follow this guide here if you haven't create your API user (username account) yet: https://forum.espocrm.com/forum/gene...0758#post60758

    Firstly I use this website as a test website since I don't have a website/API readily available yet to test it yet.

    Go to: https://webhook.site/
    Copy the "Your Unique URL"
    To go your EspoCRM, for example: https://crm.com/#Webhook/
    Click on "Create Webhook"
    Under Event, let test it with "Leads.Create"
    Under URL, paste what you copy from "Your Unique URL"
    Choose an API user
    Wait for the Webhook CRON job to be finish (default setting is every 5 minutes).
    Go back to the website tab of https://webhook.site/ ; on the left side you should see it did a "POST".

    Congratulation, you just Webhook from EspoCRM to another website. Next time I will explore some real usage example, but at least there is something to get started.

    Anyway here is the official documentations which was quite meaningless to me considering my skill level. https://docs.espocrm.com/administration/webhooks/

    Leave a comment:


  • esforim
    commented on 's reply
    I'll post some Screenshot to show-off in the future to gather some interest

  • esforim
    replied
    Celebration time!

    I have finally manage to make some success with an "open" Mobile CRM App. For the boring history lesson it is below.

    For those that want to contribute to making it and working on it with me feel free to check it out here:



    So Figma is the GUI design and Bravo Studio is the code and building the app.

    It is fairly easy to use from my initial test (and it working unlike my other test and trial!). If you have any question feel free to ask or discuss it in here, I'm fairly new to it but I will slowly make progress to it and you can adopt your own version or help me create it. I can send Edit invite through PM.

    ---

    History (for learning):

    My coding is terrible, even after all many tutorials and guide I still make almost no progress to creating an Mobile App. There is a few that exist currently but it is Closed Source or Subscription Pay, some doesn't work on my version either but more importantly I or no one can't make change to it or creating their own version.

    Anyway I eventually came across a few other option (such as Webapp but at the end of the day those doesn't fit my criteria and need). Finally I found out about these "Codeless" or "Low-code" App creator, but most from what I see have restriction that won't work in the long run.

    Finally, yesterday I decide to give it another try, to see if there is "something" out there yet and came across Bravo Studio. On the initial testing with their Sample Apps, it look great, work well with their existing database and structurally and skill-wise it is something a Programmer-less like me can work on.

    My first goal is to get some of the basis function working so I can use the App.

    There is some weakness in the Free Plan which is what I'm using though, and that is it can only do "Get" (get data), it cannot do "POST" (send/update data), you have upgrade your plan for that.

    Leave a comment:


  • item
    replied
    Hello,
    pdo_sqlite is not needed by espoCRM.
    for me, if SSD.. ram is enough (i have 4mb) .. php7.4 it's ok.. you problem is in setting of mysql/mariaDb or maybe in last php.ini setting.

    As Yuri say, the bootness (le goulot) is database..
    I know i have same bug in the past : 150000 record import by cron ... "database go away"... we have tuned my.cn (mysql setting file) and change to SSD and no more issue.
    i think this is our file :
    PHP Code:
    
    [client]
    port = 3306
    socket = /var/lib/mysql/mysql.sock
    
    [mysqld_safe]
    socket = /var/lib/mysql/mysql.sock
    nice = 0
    
    [mysqld]
    user = mysql
    pid-file = /var/lib/mysql/web01.pid
    socket = /var/lib/mysql/mysql.sock
    port = 3306
    basedir = /usr
    datadir = /var/lib/mysql
    tmpdir = /tmp
    skip-external-locking
    
    bind-address = 127.0.0.1
    
    
    # InnoDB parameters
    innodb_file_per_table = 1
    innodb_buffer_pool_size = 256M
    innodb_thread_concurrency = 8
    innodb_flush_log_at_trx_commit = 1
    innodb_log_buffer_size = 1M
    
    # MyISAM parameters
    key_buffer = 16M
    myisam-recover = BACKUP
    
    # Query cache parameters
    query_cache_limit = 1M
    query_cache_size = 128M
    
    # Table cache parameters
    table_cache = 64
    
    # Global timeouts
    wait_timeout = 120
    interactive_timeout = 120
    
    # Various parameters
    max_allowed_packet = 16M
    thread_stack = 256K
    thread_cache_size = 8
    log_error = /var/log/mysqld.log
    expire_logs_days = 10
    max_binlog_size = 100MB
    max_connect_errors = 4294967295
    
    # Max connections
    max_connections = 150
    max_user_connections = 0
    
    
    [mysqldump]
    quick
    quote-names
    max_allowed_packet = 16M
    
    [mysql]
    [isamchk]
    key_buffer = 16M
    !includedir /etc/mysql/conf.d/ 
    

    Leave a comment:


  • esforim
    replied
    PHP 7.4. Here current extensions list (I recently disable pdo_sqlite) and see how it go.

    Leave a comment:


  • esforim
    commented on 's reply
    There is only like 1-3 user (just myself mostly, and it only get access through browser website), usage wise it my server got plenty that still can be use (RAM), it is a SSD from what I was advised.

    The 'user' in case is "User connection to mySQL server", I believe each request to a database = 1 user connection, it outside of my knowledge aside from reading article online in relation to the error. For some reason when it come to email fetching it make 20+ connection to mySQL server and the server must have timeout the connection causing no email to be imported.

    I tried reducing the email fetching concurrent setting but still not luck. Going to keep playing with it

    A quick check (as I post this) that I'm only using 1.5% CPU, 157MB RAM (of 3GB), so something is amiss here.
    Last edited by esforim; 12-07-2020, 02:08 AM.

  • item
    commented on 's reply
    How Many Users ? How RAM ? HDD or SSD ? espo version ? mysql ? php ?

  • esforim
    commented on 's reply
    People been telling me it due to too much "user" (ie. connection), hence it timing out. But I have a feeling it due to one of the non-working extensions or compatibility. They just want me to to upgrade to a higher user package.

    Reading your post I decide to change/disable some of the extension. Hopefully I see a miracle and it start working again. My email usage isn't that much so it shouldn't affect the CRM like this. I don't use Mass Email.

  • item
    commented on 's reply
    Helle espcrm,
    as i can read this : https://stackoverflow.com/questions/...sql-extensions :
    "Since libmysql returns numeric types as strings, I use mysqlnd with nd_pdo_mysql in order to get native/strict data, so that numeric types are NOT returned as Strings"

    i understand why MySQL gone away

    Cron is more simple to debug than email import

  • esforim
    replied
    Hi guys,

    Just notice an "CRON not enable" message today in the Admin panel so I investigate and it seem that this error is related to it:


    Code:
    Espo.ERROR: Uncaught Exception PDOException: "could not find driver" at /home/public_html/crm/application/Espo/ORM/EntityManager.php line 272 {"exception":"[object] (PDOException(code: 0): could not find driver at /home/public_html/crm/application/Espo/ORM/EntityManager.php:272)"} []
    Searching around it seem to be related to the extensions PDO; I had a look at my PHP options and it is enable (PDO_mysql). My host also have nd_pdo_mysql available as well, if you enable one the other get disable.

    Anyway it seem that PDO_mysql does not work for me so I decided enable nd_pdo_mysql and my CRON get enable again.

    Thinking about this, I have a feeling nd_pdo_mysql is what causing my email not to importable and I keep getting.

    Code:
    Espo.ERROR: Uncaught Exception PDOException: "SQLSTATE[HY000]: General error: 2006 MySQL server has gone away" at /home/public_html/crm/application/Espo/ORM/SqlExecutor.php line 72 {"exception":"[object] (PDOException(code: HY000): SQLSTATE[HY000]: General error: 2006 MySQL server has gone away at /home/public_html/crm/application/Espo/ORM/SqlExecutor.php:72)"}

    Leave a comment:

Working...