function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Steve Connelly 5Steve Connelly 5 

How do i code this?

Stuch on how to code this:

Starting with this…
string created = opportunityList.Quarter_Created_op__c;
decimal year = opportunityList.Start_Year__c;
decimal quarter = opportunityList.Start_Quarter__c;
decimal span = opportunityList.Quarters_Spanned_op__c;

decimal counter1 = 0;
while (counter1 < span )
{

......................................................................

How do I code this?


If quarter is =< 4
Output = year + quarter (for use in next step) should look something  like this (2019-Q1 or 2019-Q2 or 2019-Q3 or 2019-Q4)

If quarter is >4 reset quarter to 1
Increment year +1
Output = year + quarter (for use in next step) should look something  like this (2020-Q1)

Each time this completes, increment quarter++ until (counter > span)


I will use the output from the above loop in creating a new record.

Any help out there for a newbiw coder?

Thanks much,
Sc
Best Answer chosen by Steve Connelly 5
Paul Karaffa 11Paul Karaffa 11
I think I understand. Essentially, you just want the 'Output' variable to holder 2019-QX, where the X is incremented? If so, do the following:

String Output = '2019-Q';
for (Integer i=0; i<4; i++) {
    Output = Output + i;
    // do stuff with the Output variable
}

^ that will loop through and create a new Output value every time until it gets to 2019-Q4 and then it will stop. :)

If this was helpful, leave a like!