How can I trigger the classification to update and change forms from a different property?

オフライン

Hi Aras Community, I have a use case where my classification is technically controlling two things. What type of workflow they are on and what kind of form they see with the ability to switch the different kinds of forms. I'm trying to prevent mistakes from happening by providing 2 drop downs one that shows the workflow type and another that offers the form options. On selecting the form options, I need to update the classification and have the form change to the proper form. My current code updates the classification but does not execute whatever code causes the form to change on the classification update the way it does if you type it in or use the classification dialog box. Below is the code I'm starting with I don't know if there may be an API I can call that does this change or if there is a way to refresh the iframe that I'm not aware of. Any help is greatly appreciated.

var inn = top.aras.newIOMInnovator();
var formtype = document.all("form_type").value;
var worktype = document.all("workflow_purpose").value;
var classification = "";

switch(worktype){
    case "New Work":
        if(formtype = "form1"){
            classification = "form1/Create New";
        }else{
            classification = formtype+"/"+worktype;
        }
        break;
    
    case "Other Work":
        if(formtype = "form2"){
            classification = "form2/Other Work";
        }else{
            classification = formtype+"/"+worktype;
        }
        break;
}

window.handleItemChange("classification",classification);
window.handleItemChange("form_type", formtype);

return this;

Parents
  • So you have classification specific Forms, but the Form doesn´t change after changing the class with your Method?

    I never tried this one, but you can try a few things:

    1. Use aras.uiReShowItem(...) to refresh the Form

    2. window.handleItemChange doesn´t work for every field type. So you sometimes cannot use it at all or have to use it in combination with a second call or have to use something completely different.

    Maybe: document.thisItem.setProperty("classification", "123"); 
    Or:: document.getElementsByClassName("classification")[0].value = "123" 
    or:  getFieldByName("classification").value = "123"

    3. Trigger the classification change event manually. But I am not sure if the Form change is really triggered by a "change" event

    const event = new Event('change');
    myClassElement.dispatchEvent(event);

    Good luck! Let me know your results :D
  • +1 オフライン in reply to AngelaIp

    Hey I ended up getting with Aras Support and they recommended the following code addition that ended up working.

    var inn = top.aras.newIOMInnovator();
    var formtype = document.all("form_type").value;
    var worktype = document.all("workflow_purpose").value;
    var classification = "";
    
    switch(worktype){
        case "New Work":
            if(formtype = "form1"){
                classification = "form1/Create New";
            }else{
                classification = formtype+"/"+worktype;
            }
            break;
        
        case "Other Work":
            if(formtype = "form2"){
                classification = "form2/Other Work";
            }else{
                classification = formtype+"/"+worktype;
            }
            break;
    }
    
    window.handleItemChange("classification",classification);
    window.handleItemChange("form_type", formtype);
    
    /*support addition*/
    parent.onRefresh();
    /*support addition*/
    return this;

Reply
  • +1 オフライン in reply to AngelaIp

    Hey I ended up getting with Aras Support and they recommended the following code addition that ended up working.

    var inn = top.aras.newIOMInnovator();
    var formtype = document.all("form_type").value;
    var worktype = document.all("workflow_purpose").value;
    var classification = "";
    
    switch(worktype){
        case "New Work":
            if(formtype = "form1"){
                classification = "form1/Create New";
            }else{
                classification = formtype+"/"+worktype;
            }
            break;
        
        case "Other Work":
            if(formtype = "form2"){
                classification = "form2/Other Work";
            }else{
                classification = formtype+"/"+worktype;
            }
            break;
    }
    
    window.handleItemChange("classification",classification);
    window.handleItemChange("form_type", formtype);
    
    /*support addition*/
    parent.onRefresh();
    /*support addition*/
    return this;

Children
No Data