Map.lookup Method [AX 2012]

Returns the value mapped to by a particular key value.

public anytype lookup(anytype keyValue)

Run On

Called

Parameters

keyValue
Type: anytype
The key to find.

Return Value

Type: anytype
The value that is mapped to by the specified key.

An exception is thrown if the key is not found in the map, so check whether the value you want to retrieve exists by using the Map.exists method.

The following example checks whether a particular style exists in a map of styles in a style sheet. If it does, a new name is substituted for the body style.

static void renameStyle(Map stylesheet, str fromName, str toName) 
{ 
    str body; 
  
    if (stylesheet.exists(fromName)) 
    { 
        body = stylesheet.lookup (fromName); 
        stylesheet.remove (fromName); 
        stylesheet.insert (toName, body); 
    } 
    else 
    { 
        info (fromName); 
    } 
}

Community Additions

ADD
Show: