0
I'm trying to do this in ModScript for SBM 11.3. It says that DATE_ONLY_FLD_1 is not equal to itself.

Ext.SetCompatibilityVersion(11,3);
var pbr = Shell.Item;
var start_dt = Variant();
pbr.ReadWithWhere("ts_id=123");
pbr.GetFieldValue("DATE_ONLY_FLD_1",start_dt); // ",start_dt" is a chai Variant / VBScript string in ISO 8601 format
if ( pbr.IsFieldEqual("DATE_ONLY_FLD_1",start_dt) ) {
ext.LogInfoMsg("equal");
} else {
ext.LogInfoMsg("not equal");
}

Accepted Answer

Saturday, March 09 2019, 04:01 PM - #Permalink
0
The problem (thanks to Daniel Iwamoto in support) turns out to be a defect (DEF253987). The work-around is to use the field's ID or Display Name in the "IsFieldEqual" call instead of Field DB Name. That does it.
The reply is currently minimized Show
Responses (2)
  • Accepted Answer

    Wednesday, March 06 2019, 05:47 AM - #Permalink
    0
    I'm not using if field is equal, but I use the following for a date comparison, just in case it helps.


    // -----------------------------------------------------------------
    // Requires that Due date must be at least today
    // -----------------------------------------------------------------
    global dtmDueDate = Variant();
    global dtmToday = Variant();
    global dtmDiff = Variant();
    global dtmTomorrow = Variant();

    Ext.SetCompatibilityVersion ( 7 ) ;
    Shell.Item().GetFieldValue("REQUIRED_DUE_DATE", dtmDueDate) ;

    if (!(dtmDueDate == "")) {
    dtmToday = Date();
    dtmTomorrow = DateAdd( "d", 1, dtmToday) ;
    dtmDiff = DateDiff( "d" , dtmTomorrow , dtmDueDate ) ;
    if ( dtmDiff < 0 ) {
    Shell.RedoMessage() = "Requested Due Date must be greater than today.";
    }
    }
    The reply is currently minimized Show
  • Accepted Answer

    Wednesday, March 06 2019, 06:16 AM - #Permalink
    0
    I found this article, it may help you. it may be the difference between the type of variable. Date vs String

    https://www.serenacentral.com/community/forums/modscript-what-type-of-value-does-isfieldequal-method-expect-for-a-date-only-field
    • Paul Thompson
      more than a month ago
      Interesting thread. The participants seem very knowledgeable, but stuck in some kind of recursive loop ;-)
    The reply is currently minimized Show
Your Reply

Recent Tweets