"NEXT_N_WEEKS" not working

  • 1
  • Problem
  • Updated 1 year ago
  • Solved
The "NEXT_N_WEEKS" date function in model conditions is not working properly for me - and neither is "NEXT_N_DAYS" or "NEXT_N_MONTHS." All of those functions only set date as the next week, or the next day, or the next month - even when I put in other numbers than 1 as the "N" value. Any ideas?
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb

Posted 1 year ago

  • 1
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Can you share your setup?
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb
Here's the model:
        <model id="thisPaymentSchedule" limit="" query="false" createrowifnonefound="false" datasource="salesforce" type="" sobject="bt_stripe__Payment_Schedule__c" doclone="">
            <fields>
                <field id="bt_stripe__Account__c"/>
                <field id="bt_stripe__Account__r.Name"/>
                <field id="bt_stripe__Auto_Capture__c"/>
                <field id="bt_stripe__Contact__c"/>
                <field id="bt_stripe__Contact__r.Name"/>
                <field id="bt_stripe__Count__c"/>
                <field id="bt_stripe__Preset__c"/>
                <field id="bt_stripe__Each_Amount__c"/>
                <field id="bt_stripe__End_Date__c"/>
                <field id="Opportunity__c"/>
                <field id="Opportunity__r.Name"/>
                <field id="bt_stripe__Payment_Method__c"/>
                <field id="bt_stripe__Payment_Method__r.Name"/>
                <field id="bt_stripe__Payment_Status__c"/>
                <field id="Id"/>
                <field id="bt_stripe__Status__c"/>
                <field id="bt_stripe__Start_Date__c"/>
                <field id="bt_stripe__Total_Amount__c"/>
                <field id="Payment_Method_Type__c"/>
                <field id="bt_stripe__Frequency__c"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="true" enclosevalueinquotes="false" field="bt_stripe__Auto_Capture__c" state=""/>
                <condition type="modelmerge" value="" field="bt_stripe__Contact__c" fieldtargetobjects="Contact" operator="=" model="thisContact" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
                <condition type="fieldvalue" value="2018-06-30" enclosevalueinquotes="false" field="bt_stripe__End_Date__c" state=""/>
                <condition type="fieldvalue" value="Generate" enclosevalueinquotes="true" field="bt_stripe__Status__c"/>
                <condition type="fieldvalue" value="NEXT_N_DAYS:30" enclosevalueinquotes="false" field="bt_stripe__Start_Date__c" state=""/>
                <condition type="modelmerge" value="" field="bt_stripe__Account__c" fieldtargetobjects="Account" operator="=" model="thisAccount" enclosevalueinquotes="true" mergefield="Id" novaluebehavior="deactivate"/>
                <condition type="fieldvalue" value="" enclosevalueinquotes="true" field="Payment_Method_Type__c" state="filterableoff" inactive="true" name="Payment_Method_Type__c"/>
            </conditions>
            <actions/>
        </model>
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb
And here is the relevant part of the snippet which is creating the rows in that mod
          paymentScheduleModel.createRow({
              additionalConditions: [
                  {field: 'Payment_Method_Type__c', value: "Credit Card"},
                  {field: 'bt_stripe__Preset__c', value: "Monthly"}
                  ], doAppend: true
          });
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I have noticed this as well in version 9 and 10. I assumed it was that I wasn't understanding what "Next N" meant. It seems to be more for creating conditions than for setting dates. For example, if you want to limit your results to only dates within the next three months, you would use Next_N_Months = 3. However, it doesn't seem to know how to set a date value for a date that is 3 months from today.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
That being said, I would love an action that could set a date out 3 months from today or from a date field in a model.
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
I have not been able to reproduce this issue in 10.0.1. I haven't tried in older versions. Does this work for you?

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">    <models>
        <model id="contact" limit="20" query="true" createrowifnonefound="false" datasource="salesforce" type="" sobject="Contact">
            <fields>
                <field id="Birthdate"/>
                <field id="FirstName"/>
                <field id="LastName"/>
            </fields>
            <conditions>
                <condition type="fieldvalue" value="NEXT_N_WEEKS:1" enclosevalueinquotes="false" field="Birthdate" state="filterableoff" inactive="true" name="Birthdate"/>
            </conditions>
            <actions/>
        </model>
    </models>
    <components>
        <buttonset model="contact" uniqueid="sk-3hByXX-152">
            <buttons>
                <button type="multi" label="Press Button To Activate Condition" uniqueid="sk-3hBzGD-156">
                    <actions>
                        <action type="activateCondition" model="contact" condition="Birthdate"/>
                        <action type="requeryModel" model="contact" behavior="standard"/>
                    </actions>
                </button>
            </buttons>
        </buttonset>
        <skootable showconditions="true" showsavecancel="true" showerrorsinline="true" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" alwaysresetpagination="false" createrecords="true" model="contact" buttonposition="" mode="read" allowcolumnreordering="true" responsive="true" uniqueid="sk-3hBcnR-109">
            <fields>
                <field id="FirstName" hideable="true" uniqueid="fi-3hBiy2-127"/>
                <field id="LastName" hideable="true" uniqueid="fi-3hBiy2-128"/>
                <field id="Birthdate" hideable="true" uniqueid="fi-3hBiy2-129"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb
Stephen - that works, but try switching NEXT_N_WEEKS:1 to be NEXT_N_WEEKS:5 or something like that. The date given there is the same as the date given with NEXT_N_WEEKS:1. Skuid is not recognizing the "N" part.
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
Certainly. Now I see. Yes, Next_N_Days will return anything within that time frame. It won't set the date to specifically N Days away. I'll add an enhancement request just for that though. It sounds like there is need for it.
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb
Got it - that is what I surmised. I would love that feature enhancement though, that would be extremely useful!

In the meantime, do you have any tips or tricks for how to set a date in a new row to be relative to today's date? I imagine it will require a snippet - have you seen this done before?
Photo of Stephen Sells

Stephen Sells, Official Rep

  • 16,856 Points 10k badge 2x thumb
I haven't personally seen this done yet. It wouldn't surprise me if someone has done it before though. 

I'll update this post if there is an addition of functionality added in a release. Thank you again for bringing this to our attention
Photo of Samuel Cohen

Samuel Cohen

  • 332 Points 250 badge 2x thumb
Thank you Stephen!
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
You could probably do it using a process, workflow, or flow in Salesforce.