Search code examples
cachingdialogaxaptax++dynamics-ax-2012

How to delete AutoComplete string in dialogFieldValue in my Dialog?


I created a Dialog I have this code:

dialog     dialog;
DialogText dialogText ;
DialogButton dialogButton;
DialogField dialogFieldI, dialogFieldII;
str fieldDel, confirm;
MyTableDelete tabledelete;

dialog = new Dialog("Dialog name");
dialog.addText("Write to confirm");
dialog.addText("DELETE");

dialogFieldI = dialog.addFieldValue(extendedTypeStr(String30), fieldDel , "Insert value");
dialogFieldII = dialog.addFieldValue(extendedTypeStr(String30), confirm, "Confirm delete");

dialog.run();
confirm = dialogFieldIi.value();
fieldDel = dialogFieldI.value();

if(dialog.closedOk() )
{
    if(confirm == "DELETE")
    {
      ttsBegin;
      select forUpdate tableDelete
      where tableDelete.field == fieldDel;
      tableDelete.delete();
      ttsCommit;
    }
}

I have a problem, when I launch the firts time, in my dialog.addFieldValue there's nothing, but If I launch the Dialog second time, in dialogField automatically appears the suggestion of the text "DELETE".

Exist a method to clean (cacheclean) after the click.

My focus is not make it easy insertion Confimr text ("DELETE").

If it were possible to know also how to compare with the uppercase in the if() statements for me it would be a good thing.

I add a pictures , I want to delete the automatic composition sentence:

my dialog

Thanks your time,

enjoy!


Solution

  • This is actually more complicated than I initially thought, unless I'm missing an easier way. I was able to reproduce your issue and the way I solved it was by using a method delAutoCompleteString() which exists on the formRun(), which is created when you call dialog.run() or it can be pre-created by calling dialog.doInit().

    This was fun to solve, so hopefully this helps someone else with the same issue. This is disabling auto complete on a form control.

    // Added these three lines in code block below

    dialog.doInit();

    dialog.formRun().delAutoCompleteString(dialogFieldI.control());

    dialog.formRun().delAutoCompleteString(dialogFieldII.control());

    Look at the adjusted code where I added these 3 lines.:

    dialog     dialog;
    DialogText dialogText ;
    DialogButton dialogButton;
    DialogField dialogFieldI, dialogFieldII;
    str fieldDel, confirm;
    MyTableDelete tabledelete;
    
    dialog = new Dialog("Dialog name");
    dialog.addText("Write to confirm");
    dialog.addText("DELETE");
    
    dialogFieldI = dialog.addFieldValue(extendedTypeStr(String30), fieldDel , "Insert value");
    dialogFieldII = dialog.addFieldValue(extendedTypeStr(String30), confirm, "Confirm delete");
    
        
    // AlexOnDAX (06/08/2015)
    // Added these lines
    //-->
    dialog.doInit();
    dialog.formRun().delAutoCompleteString(dialogFieldI.control());
    dialog.formRun().delAutoCompleteString(dialogFieldII.control());
    //<--
        
    dialog.run();
    confirm = dialogFieldIi.value();
    fieldDel = dialogFieldI.value();
    
    if(dialog.closedOk() )
    {
        if(confirm == "DELETE")
        {
            ttsBegin;
            select forUpdate tableDelete
            where tableDelete.field == fieldDel;
            tableDelete.delete();
            ttsCommit;
        }
    }