Open Closed

Oragainzation unit Custmiztion #6365


User avatar
0
mina created
  • ABP Framework version: v7.4.4
  • UI Type: Blazor WASM
  • Database System: EF Core (SQL Server,)
  • Tiered (for MVC) or Auth Server Separated (for Angular): /no
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

Dear All,

1- Is there a way to Customize the Organization unit, such as to change the coding Mechanism? 2- Can we have several organization Units in the same application for example for Location and Category?

Thanks, Mina.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

11 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Is there a way to Customize the Organization unit, such as to change the coding Mechanism

    You can replace the OrganizationUnitManager to override the GetNextChildCodeAsync method

    Can we have several organization Units in the same application for example for Location and Category?

    1 : You can use organization Units as Location and Category, you need to differentiate between them in business

    Organization Units
    
    Location A
        Location A-a
        Location A-b
    
    Location B
        Location A-a
        Location A-b
    
    Category A
        Category A-a
    

    2: You can create new organization tree entities for Location and Category.

    Here is a library that can help you simplify the development process: https://github.com/maliming/Owl.GeneralTree

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mina created

    For Question Number 1: 1- For Example, if we need to change the CodeUnitLength, as it is a static class, we can't Override, so what is the right way to do it?

    namespace Volo.Abp.Identity;
    public static class OrganizationUnitConsts
    {
    
    
        /// <summary>
        /// Length of a code unit between dots.
        /// </summary>
       ** public const int CodeUnitLength = 5;**
    
     }
    

    2- For Question 2 , will check the option and revert back to you.

    Thanks, Mina.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    For Example, if we need to change the CodeUnitLength, as it is a static class, we can't Override, so what is the right way to do it?

    It's not a big problem.

    You can change the length of the OrganizationUnit entity:

    protected override void OnModelCreating(ModelBuilder builder)
    {
        .....
        
        // Update the code length
        builder.Entity<OrganizationUnit>(b => 
        {
            b.Property(x => x.Code).HasMaxLength(10);
        });
    }
    

    dotnet ef migratons add change_code_length dotnet ef database update

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mina created

    That is not what we meant, we need to create the code for Example with 3 digit such as 000.000.000 not with the default 5-digits 00000.00000.00000

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Ok, I think I explained it above: You can replace the OrganizationUnitManager to override the GetNextChildCodeAsync method

    For example:

    [ExposeServices(typeof(OrganizationUnitManager))]
    public class MyOrganizationUnitManager : OrganizationUnitManager
    {
        public override async Task<string> GetNextChildCodeAsync(Guid? parentId)
        {
            var code = await base.GetNextChildCodeAsync(parentId);
            return code.SubString(2);
        }
    }
    
    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mina created

    For the below provided Solution: Organization Units

    Location A Location A-a Location A-b

    Location B Location A-a Location A-b

    Category A Category A-a

    if we have one Entity such as Book that should has Location and Category and both will be implemented by Organization Unit as above , how we could add the property in the Book Entity

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    The organizational units provided by ABP are used to organize users and roles.

    I suggest that you create Category and Location entities instead of using organizational units.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mina created

    Do you mean to use this "Here is a library that can help you simplify the development process: https://github.com/maliming/Owl.GeneralTree"

    is there a guide on how to integrate it into our ABP application?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Here is a simple project: https://github.com/maliming/Owl.GeneralTree/tree/dev/app

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    mina created

    I mean, is there a way or guide to add an existing Module(this app) to My existing APP?

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    No such guide, and the app is not a module. This is a sample project using this library.

    You can refer to it.

    And the Owl.GeneralTree is a library to help you develop tree entities. It provides some practical methods, such as adding deletions and moving tree nodes.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.