Community
Showing results for 
Search instead for 
Do you mean 
Reply

Need a Sample Code to Count all New Opportunities under 3 days for Example

New Member
Posts: 9
Country: France

Need a Sample Code to Count all New Opportunities under 3 days for Example

[ Edited ]

Hi All,

 

I am a new in ACT! SDK and I need so much help please. I started practicing what allowed me to understand how the SDK works and also to understand how to import references, assemblies and dll files but then that I am new and maybe there is someone here who has already written a code that allows to display the numbers of new, open, won, lost, closed won, closed lost opportunities...
I am interested in everything that can help me more.

Bronze Super Contributor
Posts: 1,271
Country: USA

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

[ Edited ]
   ' Build the Lookup criteris
     Dim fldCriteriaDateField As Act.Framework.MutableEntities.MutableEntityFieldDescriptor = Me.HostFramework.Opportunities.GetFieldDescriptor("TBL_OPPORTUNITY.CREATE_DATE", True)
     Dim cCriteriaColumnDateField As CriteriaColumn = Me.HostFramework.Lookups.GetCriteriaColumn(fldCriteriaDateField)
     Dim lCriteria() As Criteria
     lCriteria = New Criteria() {New Criteria(Act.Framework.Lookups.LogicalOperator.And, 1, 0, cCriteriaColumnDateField, OperatorEnum.OnOrAfter, "8/27/2019 12:00:00 AM"),
                                 New Criteria(Act.Framework.Lookups.LogicalOperator.End, 0, 1, cCriteriaColumnDateField, OperatorEnum.OnOrBefore, "8/30/2019 11:59:59 PM")}

     ' Do the lookup
     Dim cOpportunityLookup As Act.Framework.Lookups.OpportunityLookup
     cOpportunityLookup = HostFramework.Lookups.LookupOpportunitiesReplace(lCriteria)
     Dim xCount As Integer
     xCount = cOpportunityLookup.GetOpportunities(Nothing).Count()

Something like this?

New Member
Posts: 9
Country: France

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Hello Jim,
Thanks for your reply, so can you explain me how this code works and some properties like "criteris" and "1Criteria".
Excuse my newbie questions.

Best regards
Highlighted
Bronze Super Contributor
Posts: 1,271
Country: USA

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Sure...

 

 

 ' Build the Lookup criteris
 
' Get the field Descriptor you want to use in the criteria
 Dim fldCriteriaDateField As Act.Framework.MutableEntities.MutableEntityFieldDescriptor = Me.HostFramework.Opportunities.GetFieldDescriptor("TBL_OPPORTUNITY.CREATE_DATE", True)
 
 
' Create a Criteria column based on the previous field Descriptor 
Dim cCriteriaColumnDateField As CriteriaColumn = Me.HostFramework.Lookups.GetCriteriaColumn(fldCriteriaDateField)
 
' Now create the criteria range
Dim lCriteria() As Criteria
lCriteria = New Criteria() {New Criteria(Act.Framework.Lookups.LogicalOperator.And, 1, 0, cCriteriaColumnDateField, OperatorEnum.OnOrAfter, "8/27/2019 12:00:00 AM"),
New Criteria(Act.Framework.Lookups.LogicalOperator.End, 0, 1, cCriteriaColumnDateField, OperatorEnum.OnOrBefore, "8/30/2019 11:59:59 PM")}
 
 
' Now you have everthing you need to perform the lookup
 
 
' Create a lookup control
Dim cOpportunityLookup As Act.Framework.Lookups.OpportunityLookup
 
' Slap the criteria into the Lookup
cOpportunityLookup = HostFramework.Lookups.LookupOpportunitiesReplace(lCriteria)
 
' Last is to ask Act to perfoen the Lookup
' Do this will return the list of Opportunities matching your criteria
cOpportunityLookup.GetOpportunities(Nothing)
 
' I simplified the Lookup Count for this example
Dim xCount As Integer
xCount = cOpportunityLookup.GetOpportunities(Nothing).Count()

 

 

Hope this helps

-- Jim 

New Member
Posts: 9
Country: France

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Can you tell what namespace I'll import because it generate me some issues

Thanks for your availability
Bronze Super Contributor
Posts: 1,271
Country: USA

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Try...

 

Act.UI

Act.Framework

Act.Framework.Lookups

New Member
Posts: 9
Country: France

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Thanks so much JIM
New Member
Posts: 9
Country: France

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

[ Edited ]

Hello Jim allow me just a little time helping me to fix this issue please.

Look it at on the attachment.

Best regards

 
Bronze Super Contributor
Posts: 1,271
Country: USA

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

[ Edited ]
The Me keyword refers to the specific instance of a class. In the case of my example code the class is the ActFramework. In all my code I call the ActFramework HostFramework as to be agnostic. 
 
In your code you need to pass a reference to the  ActFramework class into your routine.
 
Sub Main(args as String(), HostFramework As Act.Framework.ActFramework )
 
Hope this helps
 
-- Jim 
New Member
Posts: 9
Country: France

Re: Need a Sample Code to Count all New Opportunities under 3 days for Example

Thanks Jim for your quick reply once again. So I have applied your solution but the "Me" is always highlighted but I finally remove it and there are no issue.

So I would like to know if I have to compile this code with Act.exe or what.?

Excuse my newbie lol

Best regards