Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Performanslı ve güvenli bir script yazmak için ipuçları

Elinizdeki bir nesneyi başka bir nesneye kopyalamak istediğinizde, bu işlemi Set komutuyla veritabanına gitmeden yapabilirsinizTips for writing a high-performance and secure script


When you request to copy an object to another object, you can do this without going to the database with the Set command.


Code Block
// KaynakReading taşımathe kabınıntarget Idcontainer siwith ilethe hedefsource taşımacontainer kabıId veritabanındanfrom okunuyordatabase
Container.Get(@@Container.Id,@@Container2)
 
// VeritabanınaAssigning gitmeden,source kaynakcontainer taşımaobject kabıto nesnesitarget hedefcontainer taşımawithout kabınagoing atanıyorto database
Set(@@Container2, @@Container)

Get işlemi, okunan nesnenin içindeki bağlantılı nesneleri de otomatik doldurur. Eğer sadece ana nesneye ihtiyacınız varsa, Get komutunun 2. parametresine nesnenin adını yazabilirsiniz.The Get operation also auto-fills the linked objects within the read object. If you only need the main object, you can type the name of the object in the 2nd parameter of the Get command.

Code Block
// BuThis işlemoperation @@Addressreads nesnesiand ilefills birliktein ilgilithe @@Warehouse, @@WarehouseFloor, @@WarehouseZone, @@WarehouseBlock nesneleriniobjects defrom veritabanındanthe okuyup doldururdatabase along with the @@Address object.
Address.Get("Address='@AdresBarkod@AddressBarcode'")
 
// BuThis işlemoperation sadeceonly @Adresfills nesnesinithe veritabanından@Address okuduğuobject adreswith bilgisiyle doldururthe address information read from the database.
Address.Get("Address='@AdresBarkod@AddressBarcode'",@Adres@Address)

Scriptteki tüm nesneler globaldir. Yani bir kez dolduğunda, boşaltılmadığı ya da başka bir komutla doldurulmadığı müddetçe dolu kalır. Kayıt hataları yaşamamak için, işlem öncesinde işlemi etkileyecek değişkenleri boşaltmalısınızAll objects in the script are global. Once it is filled in, it stays filled unless it is reset or filled by another command. To avoid saving errors, you should reset the variables to affect the operation before the operation.

Code Block
// ResetVariables komutucommand hafızadakiresets değişkenlerivariables boşaltırin memory.
ResetVariables({"name":["@@ProductionOrder","@@ProductionOrderLine","@@WorkOrder","@@WorkOrderLine","@@OrderSlip","@@OrderSlipLine","@@Arp"]})

Sık yaptığınız işlemleri ortak bir forma taşıyarak oradan çağırabilir, scriptinizin daha kısa ve derli toplu olmasını sağlayabilirsinizYou can call the frequently performed operations by transferring them to a public form, and you can make your script shorter and compacter.

Code Block
Set(@YetkiKodu@AuthorizationCode, "GIRISENTRY") // AdresAssigning içinthe kullanılacakauthorization yetkicode koduto değişkeneuse atanıyor
for the address to the variable
CallForm(AdresListeleSecListSelectAddress) // Adres seçimCalling formuthe çağrılıyoraddress selection form
If(@AdresSecimSonucu @AddressSelectionResult= -1,Goto(BasaDon)) // Formdan hatalıRedirecting sonuçthe dönmüşse script yönlendiriliyorif the wrong result is returned from the form
 
BeginForm(AdresListeleSecListSelectAddress) // OrtakPublic adresaddress seçimselection formuform
    Set(@AdresSecimSonucu@AddressSelectionResult, 0) // SonuçResetting değişkeniresult sıfırlanıyorvariable
    Address.List("AuthCode='@YetkiKodu@AuthorizationCode'","",@AdresListesi@AddressList)
    If(@AdresListesi@AddressList.rowCount<1)
        ShowMessage({"title":"UYARIWARNING","message":"TanımlıNo AdresAddress BulunamadıDefined","buttons":"TAMAMOK"},@Secenek@Option)
        Set(@AdresSecimSonucu@AddressSelectionResult, -1) // SonuçIncorrect değişkeniresult hatalıvariable
olarak belirleniyor     Else()
        If(@AdresListesi@AddressList.rowCount = 1) // TekIf adresthere varsais direkt @@Address değişkenine atanıyoronly one address, it is assigned directly to the @@Address variable
             Address.Get(@AdresListesi@AddressList.rows.1.Id) 
        Else() // BirdenIf çokthere adresare varsamore listedenthan seçipone yaptırılıyoraddress, it is selected from the list
            PopupView(@AdresListesi@AddressList.rows,{"mode":"list","title":"KabulAcceptance AdresAddress ListesiList","fields":["Address|AdresAddress TanımıDefinition|15|L"]},@sira@order)
            Address.Get(@AdresListesi@AddressList.rows.@sira@order.Id)
        EndIf()
    EndIf()
    ReturnForm() // BuReturning formuto çağıranthe satıraline gerithat dönülüyorcalled this form
EndForm()

Sık kullandığınız sabitleri bir kez tanımlayıp, scriptin her yerinde kullanabilirsinizYou can define your favorites once and use them everywhere in the script.

Code Block
// Set komutucommand JSONsupports yapısındavariable değişkenassignment atamasınıin desteklerJSON structure.
Set(@EmirDurum@OrderStatus, {"BekliyorPending":12,"IslemeAlindiProcessing":13, "TamamlandiCompleted":14})
 
// EmirThe statüsüorder tamamlandıstatus olarak belirleniyor. JSON nesnelerin alt nesnelerine . (nokta) ile erişilebiliris set as completed. The sub-objects of JSON objects can be accessed with . (dot).
CustomState.Get(@EmirDurum@OrderStatus.Tamamlandi)

...

Completed)

Do not use SQL command to fill in objects from the database unless necessary. The List and Get commands retrieve data by performing many checks, including permissions.

Code Block
// KullanıcınınIt yetkisi olduğu-olmadığı, aktif firmaya ait olan-olmayan, kullanımda olan-olmayan bütün depoları getirirretrieves both the active and inactive warehouses of both the active and inactive company, whether it is authorized by that user.
Sql("SELECT * FROM SysWarehouse", @Depolar@Warehouses)
 
// SadeceIt aktifretrieves firmayaonly ait,the kullanımdaactive olanwarehouses veof othe kullanıcınınactive yetkisicompany, olanwhich depoları getiriris authorized by that user.
Warehouse.List("","", @Depolar)

...

@Warehouses)

Do not use SQL commands for database update operations unless necessary. The Save command performs many checks while saving.

Code Block
// FişUpdates statüsünüthe Entegreslip Edildistatus olarakas güncellerIntegrated amabut entegrasyonu tetiklemezdoes not trigger the integration.
Sql("UPDATE Slip SET StateId=19", @sonuc@result)
 
// FişUpdates statüsünüthe Entegreslip Edildistatus olarakas güncellerIntegrated veand ointegrates statününinto otomatikERP eylemias olarakan ERP'yeautomatic entegreaction olmasınıof sağlarthat status.
CustomState.Get(19)
Slip.Save()