Alpha Software Mobile Development Tools:   Alpha Anywhere    |   Alpha TransForm subscribe to our YouTube Channel  Follow Us on LinkedIn  Follow Us on Twitter  Follow Us on Facebook

Announcement

Collapse

The Alpha Software Forum Participation Guidelines

The Alpha Software Forum is a free forum created for Alpha Software Developer Community to ask for help, exchange ideas, and share solutions. Alpha Software strives to create an environment where all members of the community can feel safe to participate. In order to ensure the Alpha Software Forum is a place where all feel welcome, forum participants are expected to behave as follows:
  • Be professional in your conduct
  • Be kind to others
  • Be constructive when giving feedback
  • Be open to new ideas and suggestions
  • Stay on topic


Be sure all comments and threads you post are respectful. Posts that contain any of the following content will be considered a violation of your agreement as a member of the Alpha Software Forum Community and will be moderated:
  • Spam.
  • Vulgar language.
  • Quotes from private conversations without permission, including pricing and other sales related discussions.
  • Personal attacks, insults, or subtle put-downs.
  • Harassment, bullying, threatening, mocking, shaming, or deriding anyone.
  • Sexist, racist, homophobic, transphobic, ableist, or otherwise discriminatory jokes and language.
  • Sexually explicit or violent material, links, or language.
  • Pirated, hacked, or copyright-infringing material.
  • Encouraging of others to engage in the above behaviors.


If a thread or post is found to contain any of the content outlined above, a moderator may choose to take one of the following actions:
  • Remove the Post or Thread - the content is removed from the forum.
  • Place the User in Moderation - all posts and new threads must be approved by a moderator before they are posted.
  • Temporarily Ban the User - user is banned from forum for a period of time.
  • Permanently Ban the User - user is permanently banned from the forum.


Moderators may also rename posts and threads if they are too generic or do not property reflect the content.

Moderators may move threads if they have been posted in the incorrect forum.

Threads/Posts questioning specific moderator decisions or actions (such as "why was a user banned?") are not allowed and will be removed.

The owners of Alpha Software Corporation (Forum Owner) reserve the right to remove, edit, move, or close any thread for any reason; or ban any forum member without notice, reason, or explanation.

Community members are encouraged to click the "Report Post" icon in the lower left of a given post if they feel the post is in violation of the rules. This will alert the Moderators to take a look.

Alpha Software Corporation may amend the guidelines from time to time and may also vary the procedures it sets out where appropriate in a particular case. Your agreement to comply with the guidelines will be deemed agreement to any changes to it.



Bonus TIPS for Successful Posting

Try a Search First
It is highly recommended that a Search be done on your topic before posting, as many questions have been answered in prior posts. As with any search engine, the shorter the search term, the more "hits" will be returned, but the more specific the search term is, the greater the relevance of those "hits". Searching for "table" might well return every message on the board while "tablesum" would greatly restrict the number of messages returned.

When you do post
First, make sure you are posting your question in the correct forum. For example, if you post an issue regarding Desktop applications on the Mobile & Browser Applications board , not only will your question not be seen by the appropriate audience, it may also be removed or relocated.

The more detail you provide about your problem or question, the more likely someone is to understand your request and be able to help. A sample database with a minimum of records (and its support files, zipped together) will make it much easier to diagnose issues with your application. Screen shots of error messages are especially helpful.

When explaining how to reproduce your problem, please be as detailed as possible. Describe every step, click-by-click and keypress-by-keypress. Otherwise when others try to duplicate your problem, they may do something slightly different and end up with different results.

A note about attachments
You may only attach one file to each message. Attachment file size is limited to 2MB. If you need to include several files, you may do so by zipping them into a single archive.

If you forgot to attach your files to your post, please do NOT create a new thread. Instead, reply to your original message and attach the file there.

When attaching screen shots, it is best to attach an image file (.BMP, .JPG, .GIF, .PNG, etc.) or a zip file of several images, as opposed to a Word document containing the screen shots. Because Word documents are prone to viruses, many message board users will not open your Word file, therefore limiting their ability to help you.

Similarly, if you are uploading a zipped archive, you should simply create a .ZIP file and not a self-extracting .EXE as many users will not run your EXE file.
See more
See less

Repeating Section Row Count based on field data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Repeating Section Row Count based on field data

    I have a repeating section. I have a logical field (checkbox) in that repeating section called 'PromoFlag'. I want to count the number of rows where 'PromoFlag' = true. I have a button on each row that sets that true or false, so I would assume a Javascript function called from this button can do this? Then I want to display that number in a textbox called 'rowcount'.

    Simple enough, huh? I can get the row count, but don't know how to do it based on a variable. Any help?

    #2
    Re: Repeating Section Row Count based on field data

    Try this in the Button event

    Code:
    var Repeatingsection = {Dialog.object}._harvestRepeatingSection('REPEATINGSECTION_1');
    var total = 0;
    for (i = 0; i < Repeatingsection.length; i++) {
        if (Repeatingsection[i].PROMOFLAG) {
            total++
        }
    }
    {Dialog.object}.setValue('rowcount', total)
    Alex Collier

    "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

    AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

    Comment


      #3
      Re: Repeating Section Row Count based on field data

      Looks good Alex! Thank you for posting that.
      NWCOPRO: Nuisance Wildlife Control Software My Application: http://www.nwcopro.com "Without forgetting, we would have no memory at all...now what was I saying?"

      Comment


        #4
        Re: Repeating Section Row Count based on field data

        Yes, awesome! Thanks, Alex!

        Comment


          #5
          Re: Repeating Section Row Count based on field data

          Now, let's say that each PROMOFLAG row has a price field 'price', and if the price is $2.99 and once there's 5 rows with the price of $2.99, change that price to $2.00. Then the 6th row would be 2.99 and so on until you hit the 10th row and then change the last 5 to $2.00.

          This is a Point Of Sale application and what I have is a sale where clothing is $2.99 or 5 for $10. Trying to now figure out how to change the pricing on each row with the PROMOFLAG to $2.00 once the row count of PROMOFLAG hits 5.

          So, the first 5 is $2.00, row 6-9 is $2.99, once we hit 10 rows, the last 5 with the PROMOFLAG change to $2.00.

          Is that confusing enough? :) Is this possible?

          Comment


            #6
            Re: Repeating Section Row Count based on field data

            Anything is possible :).

            This is actually easily done with some simple math.

            I will note though this example assumes all items within the repeating section are at the same discount amount / and within the same discount pool. I have attached an example UX, as posting the code alone may not help.

            Code located on the Button onClick event

            Code:
            var promo = {dialog.object}.getValue('PROMOFLAG');
            if(promo === false){
            	{dialog.object}.setValue('PROMOFLAG', true);
            }else{
            	{dialog.object}.setValue('PROMOFLAG', false);
            };
            
            var Repeatingsection = {dialog.object}._harvestRepeatingSection('REPEATINGSECTION_1');
            var total = 0;
            for (i = 0; i < Repeatingsection.length; i++) {
                if (Repeatingsection[i].PROMOFLAG) {
                    total++;
                }
            };
            
            {dialog.object}.setValue('rowcount', total);
            
            var price = {dialog.object}.getValue('price');
            var discountPrice = {dialog.object}.getValue('discountPrice');
            var bulkQtyDiscount = {dialog.object}.getValue('discountBulkQty');
            var qtyDiscountGroup = Math.floor(total / bulkQtyDiscount);
            var remainer = total % bulkQtyDiscount;
            
            var discountPriceSubTotal = discountPrice * qtyDiscountGroup * bulkQtyDiscount;
            var nonDiscountPriceSubTotal = price * remainer; 
            var PriceTotal = discountPriceSubTotal + nonDiscountPriceSubTotal;
            
            {dialog.object}.setValue('totalPrice', PriceTotal);
            Attached Files
            Alex Collier

            "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

            AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

            Comment


              #7
              Re: Repeating Section Row Count based on field data

              Looks to be exactly what I'm looking for in a roundabout way. Now I have to implement in my process. Thank you so much!! Genius!

              Comment


                #8
                Re: Repeating Section Row Count based on field data

                While playing with this I came up with this question.

                Is it possible, instead of doing the math, to actually change the 'price' field in the repeating section based off of what is in the discountPrice and blukQtyDiscount fields if the PROMOFLAG is checked?

                Comment


                  #9
                  Re: Repeating Section Row Count based on field data

                  Not sure i follow your logic here. Each repeating section is not aware of its surrounding fields. therefore without a loop over the repeating section you could not apply the discount when you select x qty i.e. 5 of any particular group of products. I don't see how you would avoid the math. I would not go with changing the value of price, if anything it should be a new field if you like. I am guessing that their is a query from the database to serve up the repeating section and in my mind should include along the other required fields a groupDiscid, Price and discountPrice. Further to that you would want to also store a query in a either one of the following data series, data side cache, viewbox or listcontrol basically something that can store a list that contains all your groupDiscid and groupDiscQty. I cant help you exactly if i don't know your exact situation. Any chance you can provide a sample of your ux, happy help you further :).
                  Alex Collier

                  "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                  AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                  Comment


                    #10
                    Re: Repeating Section Row Count based on field data

                    This works.

                    Code:
                    function setPromoprice(){
                    
                    	var d1 = {dialog.Object}.getValue('promoprice');
                    	var rc = {dialog.object}.getValue('rowcount');
                    	var rows = {dialog.Object}._getRepeatingSectionRowCount('CONTAINER_3');
                    		for (var i = 1; i < rows+1; i++) {
                    			{dialog.Object}.setRepeatingSectionActiveRow('CONTAINER_3',i);
                    
                    	var d2 = {dialog.Object}.getValue('promo');
                    		if (d2 == true && rc % 5 === 0) {
                    			{dialog.Object}.setValue('Price',d1);
                    		}
                    	}
                    
                    }

                    Each row has the price, qty, then total. Total is price*qty of course.

                    This goes and gets the 'promoprice' which would be the sale price if you buy 5, or a multiple of 5. i.e. 5 for $10.
                    Gets the 'rowcount'
                    Gets the repeating section they're in.
                    Gets the value of 'promo' which is a logical field saying that this item is part of the sale.
                    Looks to see if d2 is 'true' and the rowcount is a muliple of 5.
                    Set the price to the 'promoprice' of all that have the 'promocount' to true.

                    Maybe I was overexplaining it to you or over thinking. Any tips on this one?

                    Here's the 3 functions that do everything. processProductData queries the database, checks if it's on sale, modifies price if it is, and fills in the repeating section row.
                    promoCount counts the rows that are on sale. (uses this to calculate 5 for $10)
                    Then setPromoprice sets the sale price if they have a muliple of 5.

                    Code:
                    function processProductData(prodData){
                    
                    	var prodObj = JSON.parse(prodData);
                    	var catPromo = prodObj.P_Active;
                    	var PStatus = {dialog.object}.getValue('PromotionStatus');
                    	var price = prodObj.price;
                    	
                    	if (catPromo == 1 && price >= 2.99){
                    		{dialog.Object}.setValue('Price',"2.99");
                    		}
                    		else
                    		{
                    		{dialog.Object}.setValue('Price',prodObj.price);
                    		}
                    		
                    	
                    	{dialog.Object}.setValue('Item_ID',prodObj.item_id);
                    	{dialog.Object}.setValue('SKU',prodObj.SKU);
                    	{dialog.Object}.setValue('TaxRateProd',prodObj.tax1);
                    	{dialog.Object}.setValue('CurrentStock',prodObj.quantity);
                    	{dialog.Object}.setValue('IsActive',prodObj.Active);
                    	{dialog.Object}.setValue('TaxExemptProd',prodObj.TaxExempt);
                    	{dialog.Object}.setValue('ItemName',prodObj.Item);
                    	{dialog.Object}.setValue('Size',prodObj.Size_1);
                    	{dialog.Object}.setValue('Category',prodObj.Category_1);
                    	{dialog.Object}.setValue('ItemNameNum',prodObj.item_name);
                    	{dialog.Object}.setValue('SizeNum',prodObj.Size);
                    	{dialog.Object}.setValue('CategoryNum',prodObj.category);
                    	{dialog.Object}.setValue('Promo',prodObj.P_Active);
                    
                    	{dialog.Object}.setValue('SKULookup',"");
                    	{dialog.object}.setValue('SKUTemp',"")
                    	
                    	{dialog.Object}.addRepeatingSectionRow('CONTAINER_3');
                    	this.value='';
                    
                    	var count = {dialog.Object}._getRepeatingSectionRowCount('CONTAINER_3');
                    	{dialog.Object}.setRepeatingSectionActiveRow('CONTAINER_3',count);
                    	
                    
                    }
                    
                    function promoCount(){
                    
                    	var Repeatingsection = {Dialog.object}._harvestRepeatingSection('CONTAINER_3');
                    		var total = 0;
                    			for (i = 0; i < Repeatingsection.length; i++) {
                      			  if (Repeatingsection[i].PROMO) {
                        		    total++
                      		}
                    	}
                    	{Dialog.object}.setValue('rowcount', total)
                    
                    }
                    
                    function setPromoprice(){
                    
                    	var d1 = {dialog.Object}.getValue('promoprice');
                    	var rc = {dialog.object}.getValue('rowcount');
                    	var rows = {dialog.Object}._getRepeatingSectionRowCount('CONTAINER_3');
                    		for (var i = 1; i < rows+1; i++) {
                    			{dialog.Object}.setRepeatingSectionActiveRow('CONTAINER_3',i);
                    
                    	var d2 = {dialog.Object}.getValue('promo');
                    		if (d2 == true && rc % 5 === 0) {
                    			{dialog.Object}.setValue('Price',d1);
                    		}
                    	}
                    
                    }
                    What yours wasn't doing is accounting for the non-sale items in the sale total. I'm sure that would have been easy to implement.

                    Let me know what you think. Thank you for your help!!!

                    Comment


                      #11
                      Re: Repeating Section Row Count based on field data

                      Any chance you could you do a quick video demo / screenshot of this component so i visually seen whats happening and a screenshot of the ux controls in the designer,.that would make my life easier in interrupting and understanding.

                      Looking at your code is every item 2.99 and all items discounted to 2 when you buy multiplies of 5. do you not have a need to make these variables as they are hard coded or is this just sample code to illustrate the scenario.
                      Alex Collier

                      "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                      AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                      Comment


                        #12
                        Re: Repeating Section Row Count based on field data

                        All items have different prices. Some $2.99, and some $3.99 and up. The sale puts them all at $2.99 and then 5 for $10.

                        I will make a video.

                        Comment


                          #13
                          Re: Repeating Section Row Count based on field data

                          Here's the link to what I'm doing.

                          https://www.screencast.com/t/o591GMZQcG

                          Comment


                            #14
                            Re: Repeating Section Row Count based on field data

                            Nice, application looks good :) Thanks for the explanation. The {Dialog.object}._harvestRepeatingSection() function is a nice undocumented function
                            Alex Collier

                            "The spread of computers and the Internet will put jobs in two categories. People who tell computers what to do, and people who are told by computers what to do"

                            AA Builds from 5221_5152 to Pre-releases >> Deploying to IIS in AWS

                            Comment

                            Working...
                            X