Sequence with custom formatting

Former Member
Former Member
It looks like when creating a sequence, it can be formatted with static Prefix. I want to link an Item_number with a sequence derived using dynamic prefix from item property value. I can do this by writing server code to prefix the sequence with a property value from the item and attach this to OnBeforeAdd server event. However I cant use the sequence as data type of the item_number property. It will not execute the server code. As I like to use the sequence data type for the item_number field, so the field will be disabled and showing 'Server assigned" on the form, but If I use a string data type for the item_number field, so I can run the server code to prefix the sequence with a property value for the item_number field. But how do I make the field to look like it has a sequence data type , e.g. shows server assigned and disabled on the Add form?
  • Hi, I do something similar. You can solve this with the use of placeholders. 1. Use your "Numbering" Method as onBeforeAdd and onBeforeCopy Server event 2. Set your item_number property to String 3. Open your Form. Set Field item_number Visible=1 and Disabled=1 4. Add a new html element that will contain the placeholders. 5. Add the following code: <script> var p1= getFieldByName("item_number").getElementsByTagName("input")[0]; p1.setAttribute("placeholder", "Server Assigned"); </script> 6. As an alternative, you can also use a onFormPopulated Method for displaying placehoders. This is helpful, when you have placehodlers that you want to reuse in various Forms. E.g. Aras Change processes often share the same amount of properties. Using a Method for the placeholders avoid that you have to define the same placeholders multible times:
    var elements = document.getElementsByTagName("input");
    for (var i= 0; i < elements.length; i++)
    {
        // Get the property this input field corresponds to
        var propName = elements[i].name;
        var phContent = "";
        
        // Choose placeholder text based on property
        switch(propName)
        {
            case "item_number":
                 phContent = "Server assigned";
                break;
            case "state":
                 phContent = "Server assigned";
                break;
        }
        elements[i].setAttribute("placeholder", phContent);
    }
    Tip: You can never have enough placeholders!