I want to sort ledgers based on masterId and show first 100 ledgers with Index. but sort is not applying correctly. Tried below code. Code: [Report: SampleLedgerSorted] Form: SampleLedgerSorted [Form: SampleLedgerSorted] Part: SampleLedgerSorted [Part:SampleLedgerSorted] Line:SampleLedgerSortedTitles, SampleLedgerSorted Repeat: SampleLedgerSorted:CustomLedgerFirst100 Scroll : Vertical [Line:SampleLedgerSortedTitles] Use : SampleLedgerSorted Local : Field : LineIndex : Set as: "Line Index" Local : Field : MasterId : Set as: "MasterId" Local : Field : Name : Set as: "Name" [Line:SampleLedgerSorted] Fields:LineIndex,MasterId,Name [Field: Name] Use: NameField Set: $Name Width:20 [Field: LineIndex] Use: NameField Set: $LineIndex Width:20 [Field: MasterId] Use: NameField Set: $MasterId [Collection: CustomLedgerSorted] Type : Ledger Fetch : Name,MasterId Sort : @@Default : $MasterId [Collection: CustomLedgerFirst100] Source Collection : CustomLedgerSorted Fetch : Name,MasterId Compute : LineIndex : ##vLineIndex Compute Var : vLineIndex: Number : IF $$IsEmpty:##vLineIndex THEN 1 ELSE ##vLineIndex + 1 Filter : First100Filter [System: Formula] First100Filter : $LineIndex <= 100 [#Menu: Gateway of Tally] Add : Key Item : Before : @@locQuit : Test Report : U : Display : SampleLedgerSorted tried adding Sort to CustomLedgerFirst100 Collection Code: [#Collection: CustomLedgerFirst100] Sort : @@Default : $MasterId but it's messing up the Index and producing wrong results. Expected Output
Use SORT in the repeat Collection..... as under [Collection: CustomLedgerFirst100] Sort : @@Default : $MasterId Also Use $$Line in the LineIndex Field
Using this we cannot get first n Leders Ex: I want first 100 ledgers only So I want to apply filter First100Filter : $LineIndex <= 100
Try to do it this way: 1. Create a Collection of Ledgers and Fetch Required things 2. Add Sort to It 3. Now, Store the First 100 Or Whatever you want in List variable Now, You have sorted by master id and you got first 100 ledgers Note: In Your current method I don't think if we use source collection the parent collection sort is going to work anyway but In function It'll work for sure.
can you explain how to achieve 3rd step without line Index? I used this pattern as I cannot use functions and require this sorting within collection using sort and filter. If you any other patterns that give expected results within collection, I will use that only.
This is very simple just think it simple Code: [Report: SampleLedgerSorted] Form: SampleLedgerSorted [Form: SampleLedgerSorted] Part: SampleLedgerSorted [Part:SampleLedgerSorted] Line:SampleLedgerSortedTitles, SampleLedgerSorted Repeat: SampleLedgerSorted:CustomLedgerFirst100 Scroll : Vertical [Line:SampleLedgerSortedTitles] Use : SampleLedgerSorted Local : Field : LineIndex : Set as: "Line Index" Local : Field : MasterId : Set as: "MasterId" Local : Field : Name : Set as: "Name" [Line:SampleLedgerSorted] Fields:LineIndex,MasterId,Name Remove if:$$Line >100 [Field: Name] Use: NameField Set: $Name Width:20 [Field: LineIndex] Use: NameField Setas: $$Line;$LineIndex Width:20 [Field: MasterId] Use: NameField Set: $MasterId [Collection: CustomLedgerSorted] Type : Ledger Fetch : Name,MasterId [Collection: CustomLedgerFirst100] Source Collection : CustomLedgerSorted Fetch : Name,MasterId Compute : LineIndex : ##vLineIndex Compute Var : vLineIndex: Number : IF $$IsEmpty:##vLineIndex THEN 1 ELSE ##vLineIndex + 1 ;Filter : First100Filter Sort : @@Default : $MasterId [System: Formula] First100Filter : $LineIndex <= 100 [#Menu: Gateway of Tally] Add : Key Item : Before : @@locQuit : Test Report : U : Display : SampleLedgerSorted
By using your pattern we get all data but show only 100 ledgers But I want to get only first 100 ledgers from database. ex: If we have 1,000 ledgers, your pattern will fetch 1,000 ledgers from DB but show only 100, but we want to fetch only 100 from db(sorted) and show only them.