web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Answered

Warning: BP Rule: [BPErrorLabelIsText]:BPErrorLabelIsText: 'className' is not a label ID

(0) ShareShare
ReportReport
Posted on by 1,552

I'm trying to solve BP warnings

my question is, if i had this code:

className2Id("ClassName")

can i just replace it with  className2Id(@"ClassName") or should I really add it to the label file i created (className2Id("@ABC:ClassName")). which is better? 

I tried to put @"ClassName"and the warning disappeared but I don't what did this @ do. I'm not sure if it's correct to use it.

I have the same question (0)
  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    Could you please share the code where you are using this function? I am wondering if you can use the classNum function instead. In case you are being passed the class name as a string, have you tried to assign the class name value to a variable and try "className2Id" function using the variable instead?

  • junior AX Profile Picture
    1,552 on at

    Here is what i used:

    FormJsonSerializer::deserializeObject(className2Id("ClassName"))

    can i replace it with anything?

    also this question is generic, i have this warning in other cases as well,

    For example if i put

    throw error("@ABC:error + "  "+ @ABC:error2);

    i'll get a best practice warning about the space "  "

    so should i make a label for the space or can i put @" "

    also for throw("error"); i'll get the same warning that it should be a label.

    i usually put labels for things that appear in the UI such as form names, field names etc..

    so the question is, as a best practice, should i make a label for everything or can i use @""

  • Verified answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    You should create a label for the the errors and warnings. I don't think you should use @ for this.

    As for the class name, please check if you can use this - FormJsonSerializer::deserializeObject(classNum(className)).

  • junior AX Profile Picture
    1,552 on at

    Hi Gunjan,

    is it true, that Microsoft will make all these BP rules warnings mandatory in the future?

    Also there are warnings without the word BP Rule, ForExample: this statement is unreachable

    What kind of warnings are these and how should i solve them. ( it appears on the break word)

    System.Net.WebException     webExc ;
            try
            {   
                System.Net.HttpWebResponse response=_request.GetResponse();
            
                using (System.IO.StreamReader streamReader  = new System.IO.StreamReader(response.GetResponseStream()))
                {
                    str webResponse = streamReader.ReadToEnd();
                    return [webResponse,response.StatusCode];
                }
    
            }
    
            catch (webExc)
            {
                System.Net.HttpWebResponse  webResponse = webExc.Response;
                         
                switch (webResponse.StatusCode)
                {
                    case 400:
                        throw Error(strFmt("@ABC:ERROR"   " "   "@ABC:ERROR1"));
                        break;
    
                    case 401:
                        throw Error(strFmt("@ABC:ERROR"   " "   "@ABC:ERROR2"));
                        break;
    
                    case 404:
                        throw Error(strFmt("@ABC:ERROR"   " "   "@ABC:ERROR3"));
                        break;
    
                    case 500:
                        throw Error(strFmt("@ABC:ERROR"   " "   "@ABC:ERROR4"));
                        break;
                    default: 
                        throw error(strFmt("@ABC:ERROR"   " "   webExc.Message));
                }
    
            }

  • Suggested answer
    Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    I am not sure if MS will make these BP rules and warnings mandatory in the future. But, it is always a good practice to take care of them.

    You are getting the "unreachable" error when the code will never be executed. In your case, you have the statement "throw error", which terminates the code execution. You can try your code instead -

    System.Net.WebException     webExc ;
    try
    {   
        System.Net.HttpWebResponse response=_request.GetResponse();
    
        using (System.IO.StreamReader streamReader  = new System.IO.StreamReader(response.GetResponseStream()))
        {
            str webResponse = streamReader.ReadToEnd();
            return [webResponse,response.StatusCode];
        }
    
    }
    
    catch (webExc)
    {
        System.Net.HttpWebResponse  webResponse = webExc.Response;
        str                         errorMsg;
                 
        switch (webResponse.StatusCode)
        {
            case 400:
                errorMsg = strFmt("@ABC:ERROR"   " "   "@ABC:ERROR1");
                break;
    
            case 401:
                errorMsg = strFmt("@ABC:ERROR"   " "   "@ABC:ERROR2");
                break;
    
            case 404:
                errorMsg = strFmt("@ABC:ERROR"   " "   "@ABC:ERROR3");
                break;
    
            case 500:
                errorMsg = strFmt("@ABC:ERROR"   " "   "@ABC:ERROR4");
                break;
            default: 
                errorMsg = strFmt("@ABC:ERROR"   " "   webExc.Message);
        }
        
        throw error (errorMsg);
    }

  • junior AX Profile Picture
    1,552 on at

    but the code gets reached, as i have an outer catch which will catch it. Or you mean because it won't reach other switch cases? (even though that's the whole idea of switch). and since this warning is not BP, should i care about it as well?

    Another thing about BP label warnings:

    So i added this label:

    pastedimage1604175941885v1.png

    and i used it somewhere in the code like

    field1+ "@ABC:Colon" + field2

    but i got this warning:

    Unknown label '@ABC:Colon'. Legacy labels (such as the label id @SYS12345) are case insensitive and modern labels (such as 'MyLabelId' in @MyLabelFile:MyLabelId) are case sensitive. Use upper casing when referring to legacy labels and exact casing for modern labels. 

    what does that mean, what's wrong?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    Hi junior AX,

    I meant that the "break" statement never gets executed since you are executing the "throw error()" just before it.

    You shouldn't have named your label file ABC, because label files with upper casing are expected to be used for legacy label files only. Did you create the model file in the same model where you are doing your customizations?

  • junior AX Profile Picture
    1,552 on at

    1. And what do you mean by legacy label file?

    2. Why this warning appears on certain erros. For example if i have this

    LabelId: ErrorMsg with label: an error has occured  then i don't get this legacy warning

    -- Yes i created in the same model where i'm doing my customizations

    3. So to solve this problem, should i rename my label file from ABC to ABCall and in this way the warning will disappear?

  • Gunjan Bhattachayya Profile Picture
    35,423 on at

    1. Legacy labels are the ones brought over from the previous version(s). For an example - SYS, HCM, GLS.

    2. Are the labels not throwing the exception belong to the same label file?

    3. You should name the label file something meaningful. For an example, you can take a look at existing labels like AccountingFramework, AccountsPayable.

  • junior AX Profile Picture
    1,552 on at

    1. So we should never name our label files with capital letters only [for newly created models]? we can use capital letters only if the are combined with small letters right?

    2. Do you mean if I get the correct result when i use ABC:Colon even though i have this warning? I didn't test it but i guess i'll be able to see the info message correctly since it's just a warning

    3. So renaming it, will remove these related BP warnings?

    I think renaming the label file will be a headache because i need to rename each field label, text, etc...

    4. why this error appeared for certain labels only and not for all labels created?

    5. By "legacy label files brought from pervious versions", you mean when moved from ax12 to d365 for example?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 660 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 549 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 307 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans