Forum Discussion

team_aras_meupe_com's avatar
3 years ago
Solved

Server Event. Code execution

Hello, I wrote the question in the following post...

  • alaxala's avatar
    alaxala
    3 years ago

    Oh, I forgot that serverEvents doesn't affect on lock events. So the only way to avoid this re-call is to use the fake property.

    Add something like this to the beginning of your method

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:656fdc25-52dc-4f9d-88a0-444c4d356b3f:type=csharp&text=if%20%28this.getProperty%28%22skipOnBeforeLock%22%29%20%3D%3D%20%221%22%29%20return%20this%3B]

    and <skipOnBeforeLock>1</skipOnBeforeLock> to codigoAML

11 Replies

  • Hello, sorry, The forum is terrible for me, I can see it, but I can't create new posts from my computer, I have to do it from my mobile. But from my computer, i can answer other posts. A disaster.

    what I was going to ask.

    I have a server side event. in the onBeforeLock event.

    Basically, I want to create an RM (itemtype ProdRef), but first I want to check that there isn't already one linked to another field of the itemtype.

    The funny thing is that it executes all the code and then gives me the error message.

    [embed:dc8ab71f-3b98-42d9-b0f6-e21e02a0f8e2:eb27c4f4-4845-4de5-9b5a-19de23779600:type=xml&text=var%20innovator%20%3D%20this.getInnovator%28%29%3B%0A%0Avar%20ID%20%3D%20this.getID%28%29%3B%0A%0A%2F%2F%20primero%20comprobamos%20que%20no%20exista%20ya%20un%20RM%20para%20este%20MAT.%20SUM.%0Avar%20codigoAML%20%3D%20%22%3CAML%3E%3CItem%20type%3D%27MT%20ProdRef%27%20action%3D%27get%27%20select%3D%27mp_prodref_mat%27%3E%3Cmp_prodref_mat%3E%22%2BID%2B%22%3C%2Fmp_prodref_mat%3E%3C%2FItem%3E%3C%2FAML%3E%22%3B%0Avar%20SentenciaRM%20%3D%20%20innovator.applyAML%28codigoAML%29%3B%0A%0Aif%20%28SentenciaRM.getItemCount%28%29%20%3E%200%20%29%7B%0A%20%20%20%20return%20innovator.newError%28%22ERROR%3A%20Ya%20existe%20un%20RM%20para%20este%20Material%20Suministrad0000o.%20%22%2B%20SentenciaRM%29%3B%0A%7D%20else%20%7B%0A%0A%2F%2F%20si%20no%20existe%2C%20continuamos%20con%20el%20proceso.%0A%0A%2F%2F%20cogemos%20los%20datos%20de%20cantidad%20y%20el%20PN.%20No%20puedo%20usar%20un%20this%2C%20es%20el%20lado%20del%20servidor%2C%20supongo%0Avar%20Datos_MAT_SUM%20%3D%20innovator.applyAML%28%22%3CAML%3E%3CItem%20type%3D%27MP_MAT_SUM%27%20action%3D%27get%27%3E%3Cid%3E%22%2BID%2B%22%3C%2Fid%3E%3C%2FItem%3E%3C%2FAML%3E%22%29%3B%20%0Avar%20Cantidad%20%3D%20Datos_MAT_SUM.getProperty%28%22mp_matsum_quant%22%2C%22NO%20CANTIDAD%22%29%3B%0Avar%20Origen%20%3D%20Datos_MAT_SUM.getProperty%28%22mp_matsum_orig%22%2C%22NO%20ORIGEN%22%29%3B%0A%0A%2F%2F%20cogemos%20el%20indice%20del%20PART%0Avar%20DatosPART%20%3D%20innovator.applyAML%28%22%3CAML%3E%3CItem%20type%3D%27Part%27%20action%3D%27get%27%20select%20%3D%27mt_par_index%27%3E%3Cid%3E%22%2BOrigen%2B%22%3C%2Fid%3E%3C%2FItem%3E%3C%2FAML%3E%22%29%3B%20%0Avar%20Indice%20%3D%20DatosPART.getProperty%28%22mt_par_index%22%2C%220%22%29%3B%0A%0A%2F%2FCreamos%20el%20RM%20y%20le%20asociamos%20el%20MAT.%20SUM.%0AcodigoAML%20%3D%20%22%3CAML%3E%3CItem%20type%3D%27MT%20ProdRef%27%20action%3D%27add%27%3E%3Cmp_prodref_mat%3E%22%2BID%2B%22%3C%2Fmp_prodref_mat%3E%3Cmt_proref_pn%3E%22%2BOrigen%2B%22%3C%2Fmt_proref_pn%3E%3Cmt_proref_index%3E%22%2BIndice%2B%22%3C%2Fmt_proref_index%3E%3Cmt_proref_qinit%3E%22%2BCantidad%2B%22%3C%2Fmt_proref_qinit%3E%3Cmt_proref_quant%3E0%3C%2Fmt_proref_quant%3E%3Cmt_proref_qused%3E0%3C%2Fmt_proref_qused%3E%3Cmt_proref_qfree%3E%22%2BCantidad%2B%22%3C%2Fmt_proref_qfree%3E%3C%2FItem%3E%3C%2FAML%3E%22%3B%0Avar%20SentenciaAML%20%3D%20%20innovator.applyAML%28codigoAML%29%3B%0A%0A%2F%2F%20le%20asignamos%20al%20MAT.%20SUM.%20el%20RM%20creado%0Avar%20id_RM%20%3D%20SentenciaAML.getProperty%28%22id%22%2C%22NO%20ID%22%29%3B%0A%0A%2F%2FA%C3%B1adimos%20el%20codigo%20del%20RM%20y%20su%20estado%20en%20MAT%20SUM%0AcodigoAML%20%3D%20%22%3CAML%3E%3CItem%20type%3D%27MP_MAT_SUM%27%20action%3D%27edit%27%20id%3D%27%22%2BID%2B%22%27%3E%3Cmp_matsum_rm%3E%22%2Bid_RM%2B%22%3C%2Fmp_matsum_rm%3E%3C%2FItem%3E%3C%2FAML%3E%22%3B%0ASentenciaAML%20%3D%20%20innovator.applyAML%28codigoAML%29%3B%0A%0Areturn%20this%3B%0A%0A%7D%0A]

    In the line 9 i have a getItemCount, but before it shows me the message, it has already executed all the code, it has created the RM and that's how it shows me the message. The bad thing is that since I created the RM before, it always tells me that there is already an RM for that code.

    I have tried to put all the code after the if in an else. And what it does is that it executes the else and then what is in the if. I don't make sense of this

    Any idea??. Too many thanks!!!

    • alaxala's avatar
      alaxala
      Creator III

      What ItemType is your onBeforeLock event linked to?