Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / "The placeholder ...
Finance forum

"The placeholder '%4' to strFmt is not used in the format string." in D365

(0) ShareShare
ReportReport
Posted on by 1,054

Hi All,

I am assigning string to container as shown below.

Container infoMessage;

infoMessage += strFmt("Ledger dimension %1-%2 Total number of lines processed %3 with total calculated interest %4", header.DimensionValues[#one], header.DimensionValues[#two], line.RecId, header.TotalCalcInterestAmount);

I am adding all the messages to the container and after the execution I will display the info messages one by one. in the above line of code I am getting "The placeholder '%4' to strFmt is not used in the format string." BP warning can any one please suggest me how can i solve this?

Thanks in advance.

  • Deepak Profile Picture
    22 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Use literalStr to validate label strings

    The literalStr Function is used to validate a string at compile time.  The parameter can either be a hard coded string (in which case, a best practices error for a hard coded string will be thrown) or, as is more often the case, a label ID.  The main benefit of using this method is that it validates the label ID passed to it at compile time and throws a best practices error if an invalid label ID is passed to it.

    This method is also often used in the contract class, for the parm methods. For example, the parm method can be decorated with SysOperationLabelAttribute attribute which specifies the label for the parameter.

    info(literalStr (StrFmt("@USMF95927",stringVar))   // Correct

    info(StrFmt("@USMF95927",stringVar))    // Incorrect

  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    moved to the d365 forum

  • Dick de Jong Profile Picture
    9 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    it is real BAD practice to use string concatenation for info messages !!!! if you ever need to translate a message, the sequence of segments / words in sentence can be really different .. it is simply a BP framework bug and still there in 10.0.8 (latest released version)...

    5635.pastedimage1581396036373v1.png

    7536.pastedimage1581396062631v2.png

    4265.pastedimage1581396086127v3.png

  • Suggested answer
    Florian Hopfner Profile Picture
    2,451 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Medhi Moalla over in BP Label Error AX 7 posted instructions how you can use the labelc.exe tool to force a regeneration of the label resources .dll. This solved the BP warning BPUnusedStrFmtArgument for me. 

    Here are his instructions:

    1. Open command line with (admin) privilege 
    2. Execute this command : 

      J:\AosService\PackagesLocalDirectory\bin\labelc.exe -metadata="J:\AosService\PackagesLocalDirectory" -output="J:\AosService\PackagesLocalDirectory\<Package Name>\Resources" -modelmodule="<Package Name>"

    Another way to force the regeneration of the label resources .dll is to simply delete it. The next build will recreate them.

  • Andrew Jones a1x Profile Picture
    130 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Not sure if it's helpful, but the BP check only seems to look at en-us label files, so if you have labels that don't exist in that language, then you will get various label-related BP errors, including the one mentioned above about strFmt.

  • Suggested answer
    Fedir Kryvyi Profile Picture
    1,026 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    It looks like an odd issue, but technically, you can replace strFmt with string concatenation to resolve this.

    InfoMessage += strFmt("Ledger dimension %1-%2 ", header.DimensionValues[#one], header.DimensionValues[#two]) + strFmt("Total number of lines processed %1", line.RecId) + strFmt(" with total calculated interest %1", header.TotalCalcInterestAmount).

    or you can put this string concatenation inside of another method to make cleaner like

    InfoMessage += this.formatString(header.DimensionValues[#one], header.DimensionValues[#two], line.RecId, header.TotalCalcInterestAmount);

  • nep Profile Picture
    on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    I am using Update10 (7.0.4641.35168).

    BPSuppressions are my best friend right now :-)

  • André Arnaud de Calavon Profile Picture
    295,305 Super User 2025 Season 1 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Probably there is a bug in the best practice check. What exact platform update are you using?

  • nep Profile Picture
    on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Hi guruprasanna

    You are not alone - I have the exact same issue.

    The infolog shows the message perfectly, but BP keeps giving the message "The placeholder '%2' to StrFmt is not used in the format string." I use a label which uses both %1 and %2, but only %2 is "punished" by BP.

    The BP Rule is [BPUnusedStrFmtArgument].

    Seems pretty strange - I expect BP checker to be false on this for some reason.

    Please let me know if you found a solution.

  • Guruprasanna Profile Picture
    1,054 on at
    RE: "The placeholder '%4' to strFmt is not used in the format string." in D365

    Hi Sukrut,

    Thanks for the reply !

    infolog display properly. but best practice setting under my model all the best practice rules are checked. can you please suggest me which all should marked as check or un-check and is their any procedure we follow to set up the best practice rules.

    Thanks in advance

    Guru

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Featured topics

Product updates

Dynamics 365 release plans