How can i tell what quotas have been pended.

So , how do you tell what quotas have been pended or not , well its easy , the Quota object gives us a child object that has all the quota cells in it that where pended. In this example we will scan the list for the ones that have been chosen , store them to a question and then pick one of them. To achieve this we will use the following metadata,

    sys_RandomQuotaPick "Random Quota to Pick from "
    text;

    sys_RandomQuotaChosen "Random Quota chosen"
    text;

And then add this into your routing changing the words “YourQuota” to the name of the quota you want to check and also the “YourQuotaQuestion” name to the name of the question used in the quota.

Dim oCell,oCat

For each oCell in QuotaEngine.QuotaGroups["YourQuota"].Quotas.WasPendedList
	sys_RandomQuotaPick = sys_RandomQuotaPick + "#" + oCell.Expression + "#"
Next

if ( sys_RandomQuotaPick = "" ) Then
	' Nothing was picked as all are full.
Else
	' Clean the name up just get the category
	sys_RandomQuotaPick = replace(sys_RandomQuotaPick,"YourQuotaQuestion.HasAnswer({","")
	sys_RandomQuotaPick = replace(sys_RandomQuotaPick,"})","")
	sys_RandomQuotaPick = replace(sys_RandomQuotaPick,"##",",")
	sys_RandomQuotaPick = "{" + replace(sys_RandomQuotaPick,"#","") + "}"
End If

oCat = cCategorical(sys_RandomQuotaPick).ran(1)
sys_RandomQuotaChosen = cText(oCat)

So what does the code do , well first off , it loops the WasPendedList object and records into a question the cell expression, now of course if you have not put the pend command in your code anywhere then nothing will happen , but if you have , you will end up with something like this in the “sys_RandomQuotaPick” question.

#YourQuotaQuestion.HasAnswer({Red})##YourQuotaQuestion.HasAnswer({Pink})#

The reason we have put this in a question is so that we can check the data and make sure things have worked correctly and also , if needed we can check to see if this question is empty or not and prevent things from happening just in case the user hits the previous button.

Anyway now we have the list of quota cells that where pended we can now randomly pick one. To do this we need to convert

#YourQuotaQuestion.HasAnswer({Red})##YourQuotaQuestion.HasAnswer({Pink})#

into

{Red,Pink}

This is done with the replace command as you can see, first off it strips outs the “YourQuotaQuestion.HasAnswer({” and “})”. Next we replace the double # with a comma and add some curly braces around the lot. now that we have got rid of all the unwanted characters we can now convert the string to categories with cCategorical and then randomly pick one. This is then stored in the question “sys_RandomQuotaChosen” so that we can keep track of what was randomly picked.

To help us understand the WasPendedList further we can add some code to our MakeQuotaInfo function described in the article “”. The code to add should come just before the last close table tag and is.

   ......
   sHTML = sHTML + "WasPended" + ctext(oCell.WasPended) + ""
  Next

  ' Loop the WasPendedList

  For each oPendedQuota in oTable.Quotas.WasPendedList
   sHTML = sHTML + "Was Pended List"
   sHTML = sHTML + "Completed" + ctext(oPendedQuota.Completed) + ""
   sHTML = sHTML + "Count" +  ctext(oPendedQuota.Count) + ""
   sHTML = sHTML + "ExactPercent" +  ctext(oPendedQuota.ExactPercent) + ""
   sHTML = sHTML + "Expression" +  ctext(oPendedQuota.Expression) + ""
   sHTML = sHTML + "Flag" +  ctext(oPendedQuota.Flag) + ""
   sHTML = sHTML + "FullName" +  ctext(oPendedQuota.FullName) + ""
   sHTML = sHTML + "ID" +  ctext(oPendedQuota.ID) + ""
   sHTML = sHTML + "IsBelowQuota" +  ctext(oPendedQuota.IsBelowQuota) + ""
   sHTML = sHTML + "MetaData" +  ctext(oPendedQuota.MetaData) + ""
   sHTML = sHTML + "Name" +  ctext(oPendedQuota.Name) + ""
   sHTML = sHTML + "OverTargetCount" +  ctext(oPendedQuota.OverTargetCount) + ""
   sHTML = sHTML + "Pending" +  ctext(oPendedQuota.Pending) + ""
   sHTML = sHTML + "PendingPercent" + ctext(oPendedQuota.PendingPercent) + ""
   sHTML = sHTML + "Percent" + ctext(oPendedQuota.Percent) + ""
   sHTML = sHTML + "Target" + ctext(oPendedQuota.Target) + ""
   sHTML = sHTML + "Type" +ctext(oPendedQuota.Type) + ""
   sHTML = sHTML + "WasPended" + ctext(oPendedQuota.WasPended) + ""

  Next

  sHTML = sHTML + ""
 Next

So now you should be able to understand the use of the WasPendList and how we can work with it. If this explanation is not clear or you would like some more help, than as always , just ask.

Leave a Comment