"NEXT_N_WEEKS" not working

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?


Can you share your setup?

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"/> <b> <condition type="fieldvalue" value="NEXT_N_DAYS:30" enclosevalueinquotes="false" field="bt_stripe__Start_Date__c" state=""/> </b> <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>

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 });<br>

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.

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.

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?




















































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.

I just tried it with 5 and 10. It worked both times. Now I have to ask: what version are you on? Is this XML not working for you?




















































We’re on 10.0.1. I pasted in that XML, pressed the button to activate the condition, clicked the plus icon to add a row, and here is the date generated:

The condition works, the key is that the date generated in the new row is Next Week rather than 10 weeks from now.

I’m glad I’m hearing that it is working but I’m confused by what you found to be the key. Could you clarify?

By “the key” I meant “the problem.” I am looking for all new rows created in this model to have a default date of 10 weeks from today (or 5 weeks from today, or N weeks from today, etc). The condition is effective when filtering already created models, but it does not set a default value of N weeks from today. That make sense?

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.

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?

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

Thank you Stephen!

You could probably do it using a process, workflow, or flow in Salesforce.