Forum Discussion
Hi community,
I think a small code sample maybe helps to find the missing piece. The following two Methods are extreme simplified versions of my current code.
The Javascript Method is called from an onClick button event in a Form. The Server Method will later grant the necessary permissions and update the list item. This list item is used for a dropdown list in the same Form. But unfortunately I still weren´t able to figure out how to get the new List values into my DOM item.
My Server method shall return a result string instead of the edited item. The result contains some information if the list was updated or if the new value was already contained in the list (not included in sample code). This sample here will just add some static new value to the list.
I assume my update problem is mainly based on the fact that I return a helpful string text text instead of the edited list item. But I wonder if can update the Form dropdown without passing the list item?
Javascript onClick button event
var result = aras.applyMethod("MY_SERVER_METHOD");
if (!result)
{
return; // No alert necessary. Error message thrown by Server Method
}
// get result text passed by server method with inn.newResult(...);
var parser = new DOMParser();
var xmlDoc = parser.parseFromString(result,"text/xml");
var resultInfo = xmlDoc.getElementsByTagName("Result")[0].childNodes[0].nodeValue;
return aras.AlertSuccess(resultInfo);
Server method MY_SERVER_METHOD - writes a new Value into an existing List (sample is very hardcoded):
Innovator inn = this.getInnovator();
Item editList = inn.getItemById("List", "FA55766F5F2540DDBA94AD79E9D82711"); // List id of 'MyList' used for dropdown
editList.setAction("edit");
Item addValue = inn.newItem("Value","add");
addValue.setProperty("label", "newvalue");
addValue.setProperty("value", "newvalue");
editList.addRelationship(addValue);
editList = editList.apply();
string result = "Value xy was added"; // fake result for keeping this code sample simple...
return inn.newResult(result); // return result as string to javascript Method