<html>
  <head>
    <meta content="text/html; charset=windows-1252"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    I would put it in the enable/disable events, so on disable it
    removes the field and on enable it adds it, you want to be careful
    not to get duplicate field definitions, so check to see if the field
    exists before adding it - it would be good to make the methods for
    creating fields and blocks a bit safer to run twice before 6.5 comes
    out<br>
    <br>
    Alan.<br>
    <br>
    <div class="moz-cite-prefix">On 18/02/16 14:48, Lennart van
      Ballegoij wrote:<br>
    </div>
    <blockquote
cite="mid:CACq25DvzutqojQh7hQ6NHuyzvbzvORSeSCC09dT5JcGn6+KrFA@mail.gmail.com"
      type="cite">
      <div dir="ltr">Hi Guys,
        <div><br>
          <div><br>
          </div>
          <div>Nobody knows the answer to this ?</div>
          <div>I really don't want to tell my clients that the module
            needs to be reinstalled, because most of them won't even
            understand how to delete the module folders from the FTP.</div>
          <div><br>
          </div>
          <div>I hope someone can help me.</div>
          <div><br>
          </div>
          <div><br>
          </div>
          <div>
            <div style="font-size:12.8px">Thanks in advance,</div>
            <div style="font-size:12.8px"><br>
            </div>
            <div style="font-size:12.8px">Kind regards,</div>
            <div style="font-size:12.8px"><br>
            </div>
            <div style="font-size:12.8px">-</div>
            <div style="font-size:12.8px"><br>
            </div>
            <div style="font-size:12.8px">Lennart </div>
          </div>
          <div style="font-size:12.8px"><br>
          </div>
          <div class="gmail_extra">
            <br>
            <div class="gmail_quote">2016-02-03 15:45 GMT+01:00 Lennart
              van Ballegoij <span dir="ltr"><<a
                  moz-do-not-send="true"
                  href="mailto:lennart@egmmedia.nl" target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:lennart@egmmedia.nl">lennart@egmmedia.nl</a></a>></span>:<br>
              <blockquote class="gmail_quote" style="margin:0px 0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                <div dir="ltr">Thanks for the tip, i forgot about the
                  version number!
                  <div><br>
                  </div>
                  <div>I've wondered about the same thing, but so far it
                    seems like the field doesn't get created on update
                    at all.</div>
                  <div>I'm starting to wonder if it's even possible to
                    create the field on a update event... :/</div>
                  <div><br>
                  </div>
                  <div>So far i've had no luck in creating the field on
                    update, i'm almost 100% sure that i'm doing the
                    field creation right, because it does work on a
                    fresh install of the module.</div>
                  <div><br>
                  </div>
                  <div>Really hope someone knows the answer to this.</div>
                  <div><br>
                  </div>
                  <div><br>
                  </div>
                  <div>Thanks in advance,</div>
                  <div><br>
                  </div>
                  <div>Kind regards,</div>
                  <div><br>
                  </div>
                  <div>-</div>
                  <div><br>
                  </div>
                  <div>Lennart </div>
                </div>
                <div class="gmail_extra"><br>
                  <div class="gmail_quote">
                    <div>
                      <div class="h5">2016-02-01 17:10 GMT+01:00 Tim
                        Mohrbach <span dir="ltr"><<a
                            moz-do-not-send="true"
                            href="mailto:preexo@googlemail.com"
                            target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:preexo@googlemail.com">preexo@googlemail.com</a></a>></span>:<br>
                      </div>
                    </div>
                    <blockquote class="gmail_quote" style="margin:0px
                      0px 0px
0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
                      <div>
                        <div class="h5">
                          <div style="word-wrap:break-word">I would have
                            done it the same way, remember to increase
                            the version number of the extension in the
                            schema xml file… sry mate I am bad help…
                            <div><br>
                              <div>I have always wondered about this:
                                does it try to create a new field
                                everytime it updates the extension or is
                                the addField method tolerant enough to
                                ingore the field in case it’s already
                                there?</div>
                              <div><br>
                              </div>
                              <div><br>
                                <div>
                                  <blockquote type="cite">
                                    <div>
                                      <div>
                                        <div>On 01.02.2016, at 22:32,
                                          Lennart van Ballegoij <<a
                                            moz-do-not-send="true"
                                            href="mailto:lennart@egmmedia.nl"
                                            target="_blank"><a class="moz-txt-link-abbreviated" href="mailto:lennart@egmmedia.nl">lennart@egmmedia.nl</a></a>>
                                          wrote:</div>
                                        <br>
                                      </div>
                                    </div>
                                    <div>
                                      <div>
                                        <div>
                                          <div dir="ltr">Hi guys,
                                            <div><br>
                                            </div>
                                            <div>I'm working on a VTiger
                                              6.4.0 Extenstion Module
                                              that sends the invoicedata
                                              to a 3rd party API.</div>
                                            <div>I'm trying to create a
                                              picklist field in the
                                              Invoice module from within
                                              my module.</div>
                                            <div><br>
                                            </div>
                                            <div>My module was already
                                              released and some clients
                                              are already using this
                                              module, so i'll have to
                                              create the field on the
                                              module update.</div>
                                            <div><br>
                                            </div>
                                            <div>But i can't seem to add
                                              the picklist field on
                                              module.preupdate or
                                              module.postupdate of the
                                              vtlib_handler in my
                                              module.</div>
                                            <div><br>
                                            </div>
                                            <div>If i uninstall/remove
                                              my module completely and
                                              add the picklist field
                                              using the
                                              module.postinstall of the
                                              vtlib_handler it does seem
                                              to create the field like
                                              it's supposed to.</div>
                                            <div><br>
                                            </div>
                                            <div>Why can't i seem to
                                              create the field on the
                                              update events of the
                                              vtlib_handler ?</div>
                                            <div><br>
                                            </div>
                                            <div>My code:</div>
                                            <div><br>
                                            </div>
                                            <div>
                                              <div>        public
                                                function
                                                vtlib_handler($moduleName,
                                                $eventType) {</div>
                                              <div>                if
                                                ($eventType ==
                                                'module.postinstall') {</div>
                                              <div>                     
                                                 
                                                $this->createConfigTable();</div>
                                              <div>                     
                                                 
                                                $this->registerInvoiceEvent();</div>
                                              <div>                     
                                                 
                                                $this->addSettingsMenu();</div>
                                              <div>                     
                                                 
                                                $this->addTypeDropdown();</div>
                                              <div>                }
                                                else if ($eventType ==
                                                'module.enabled') {</div>
                                              <div>                     
                                                 
                                                $this->registerInvoiceEvent();</div>
                                              <div>                }
                                                else if ($eventType ==
                                                'module.disabled') {</div>
                                              <div>                     
                                                 
                                                $this->deregisterInvoiceEvent($moduleName);</div>
                                              <div>                }
                                                else if($event_type ==
                                                'module.preupdate') {</div>
                                              <div>                     
                                                 
                                                $this->addSettingsMenu();
                                                                       </div>
                                              <div>                }
                                                else if($event_type ==
                                                'module.postupdate') {</div>
                                              <div><span style="white-space:pre-wrap">                    </span>$this->addTypeDropdown();
                                                //Trying to create my
                                                Picklist field here !</div>
                                              <div><span style="white-space:pre-wrap">            </span>}
                                                else if($event_type ==
                                                'module.preuninstall') {</div>
                                              <div>                     
                                                 
                                                $this->deleteConfigTable();</div>
                                              <div>                     
                                                 
                                                $this->deregisterInvoiceEvent($moduleName);</div>
                                              <div>                }</div>
                                              <div>        }</div>
                                            </div>
                                            <div><br>
                                            </div>
                                            <div>
                                              <div>        public
                                                function
                                                addTypeDropdown(){</div>
                                              <div><br>
                                              </div>
                                              <div>            $module =
Vtiger_Module::getInstance('Invoice');</div>
                                              <div>           
                                                $blockInstance =
                                                Vtiger_Block::getInstance('LBL_INVOICE_INFORMATION',
                                                $module);</div>
                                              <div><br>
                                              </div>
                                              <div>           
                                                $fieldInstance = new
                                                Vtiger_Field();</div>
                                              <div>           
                                                $fieldInstance->name
                                                = 'typeofinvoice';</div>
                                              <div>           
                                                $fieldInstance->label
                                                = 'Soort factuur';</div>
                                              <div>           
                                                $fieldInstance->table
                                                = 'vtiger_invoice';</div>
                                              <div>           
                                                $fieldInstance->column
                                                =
                                                $fieldInstance->name;</div>
                                              <div>           
                                                $fieldInstance->columntype
                                                = 'VARCHAR(100)';</div>
                                              <div>           
                                                $fieldInstance->uitype
                                                = 15; //15 Staat voor
                                                dropdown.</div>
                                              <div>           
                                                $fieldInstance->typeofdata
                                                = 'V~M';</div>
                                              <div>           
                                                $fieldInstance->summaryfield
                                                = 1; //Display in
                                                summaryview.</div>
                                              <div>           
                                                $fieldInstance->setPicklistValues(
                                                Array ('Factuur',
                                                'Creditfactuur') );</div>
                                              <div>           
                                                $blockInstance->addField($fieldInstance);</div>
                                              <div>        }</div>
                                            </div>
                                            <div><br>
                                            </div>
                                            <div><br>
                                            </div>
                                            <div>
                                              <p style="margin:0px 0px
                                                1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica
Neue',Helvetica,sans-serif;line-height:19.5px">Hopefully someone can
                                                give me a push in the
                                                right direction.</p>
                                              <p style="margin:0px 0px
                                                1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica
Neue',Helvetica,sans-serif;line-height:19.5px">Thanks in advance :)<br>
                                                <br>
                                              </p>
                                              <p style="margin:0px 0px
                                                1em;padding:0px;border:0px;font-size:15px;clear:both;font-family:Arial,'Helvetica
Neue',Helvetica,sans-serif;line-height:19.5px">Lennart</p>
                                            </div>
                                            <div><br>
                                            </div>
                                          </div>
                                        </div>
                                      </div>
_______________________________________________<br>
                                      <a moz-do-not-send="true"
                                        href="http://www.vtiger.com/"
                                        target="_blank">http://www.vtiger.com/</a></div>
                                  </blockquote>
                                </div>
                                <br>
                              </div>
                            </div>
                          </div>
                          <br>
                        </div>
                      </div>
                      _______________________________________________<br>
                      <a moz-do-not-send="true"
                        href="http://www.vtiger.com/" rel="noreferrer"
                        target="_blank">http://www.vtiger.com/</a><br>
                    </blockquote>
                  </div>
                  <br>
                </div>
              </blockquote>
            </div>
            <br>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
<a class="moz-txt-link-freetext" href="http://www.vtiger.com/">http://www.vtiger.com/</a></pre>
    </blockquote>
    <br>
  </body>
</html>