Skip to Content
Author's profile photo Astrid Burghart

Implementing Reuse Library to perform similar validations on different Objects and raise the error messages

Hello everybody,

in my Project, there was a requirement to perform similar checks on different Transactions, especially Opportunity and Lead.

As a good programmer I have learnt, not to implement the same code multiple times, use a reuse method instead. That’s why I started using a Reuse Library in C4C. My requirement was that I had to raise an error message, when the check wasn’t successful. As I knew, it is impossible to raise a message from a reuse function, so I asked here on SCN for help.

You can check it here:

With the provided help, I have achieved my requirements by creating a Reuse Library for performing checks and raise messages (indirectly 😉 )

Here are the steps that I have performed to achieve this:

  1. Create a Reuse Library (CheckSomething.library)
  2. Create a Function (CheckField)
  3. As return Parameter I have checked the Checkbox “CollectionOf” and as Type I use “LANGUAGEINDEPENDENT_LONG_Text
    (I need the possibility to create more than one Message, that’s why I used a collection. If you only need one Message, just leave the Checkbox blank)
  4. (Optional) depending on your check, you can handover some Parameter. As we want to reuse it in different Transaction, you can handover for example the Value you want to do a check on. I have implemented 2 Parameters that I have to Import.
  5. Activate the CheckSomething.library, the Function is created automatically. Then you can implement it.
    Here is some example coding:

    import ABSL;

    import AP.Common.GDT;

    var text_collection : collectionof LANGUAGEINDEPENDENT_LONG_Text;


    //Implement the Check on the value

    if(<condition = true>)


           //Fill the text collection with the needed error messages

    1. text.content = “<Your Error Message>”;



    return text_collection;

    This is just a part of my code. I have also implemented a loop, to fill my Collection with more Texts. If you don’t have a collection, just return the text.

  6. Implement a Message in the XBOs (Opportunity.xbo, Lead.xbo, …)

    [Extension] businessobject AP.CRM.Global:Opportunity

    raises MsgInvolvedParties


           message MsgFromReuse text “&1”:LANGUAGEINDEPENDENT_LONG_Text;


    I am using “&1” to fill the message with any Text I want when raising the message.

  7. I have implemented the OnSave-Validation (if you want to rise only the Incidents, Implement the AfterModify).
    Logic that I have implemented on On-Save was that when the message collection is filled, my check was successful to catch the error in User Inputs. So the Transaction shouldn’t be saved and the message should appear.

    var message : LANGUAGEINDEPENDENT_LONG_Text;

    var message_Collection : collectionof LANGUAGEINDEPENDENT_LONG_Text;

    message_Collection = CheckSomething.Check(<your Attributes>);

    if(message_Collection.Count()> 0)


           return = false;

           foreach(var text in message_Collection)


                 message = text;

                 raise MsgInvolvedParties.Create(“E”, message);



    return return;

  8. After this implementation, perform testing.

I hope this helps someone who has a similar requirement.

Kindly provide your valuable feedback to improve this implementation. 😉

Special thanks to all who helped me to implement this. ➕

Astrid 🙂

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Chandan Bankar
      Chandan Bankar

      Great Work 🙂



      Author's profile photo Sumeet Narang
      Sumeet Narang

      Good Blog, Thanks for sharing this.

      Author's profile photo Sergey Makushynski
      Sergey Makushynski

      Hi Astrid,

      Looks great!

      Can you please share the DataType you used for parameter to import?