Quantcast
Channel: Microsoft Dynamics SL Forum - Recent Threads
Viewing all articles
Browse latest Browse all 2378

Custom default value in field changing on save

$
0
0

Hi all,

First time customizing a screen in SL and I'm trying to set the default value of the Terms ID (retrieved from the project level) on the Invoice and Adjustment Maintenance screen (BI.BAM.00) when creating a new draft. Currently, it defaults correctly while making the draft but when I click save to create it, the value is changed to the old default value.

Code:

Private Sub Form1_Display()

End Sub
Sub Form1_Load()
    Call SqlCursor(c1, NOLEVEL)

End Sub
Sub cTerms_Default(newvalue$, retval%)
    Dim strSQLStmt As String
    Dim strTermsID As String
    Dim strProjectID As String
    
    strProjectID = GetObjectValue("cbill_project")
    
    strSQLStmt = ""
    strSQLStmt = "SELECT CASE WHEN c.termsid IS NULL OR c.termsid = '' THEN '00' ELSE c.termsid END AS termsid " & _
                 "FROM pjproj as p LEFT OUTER JOIN pjcont as c on p.contract = c.contract " & _
                 "WHERE p.project = " & SParm(strProjectID)
    'MsgBox strSQLStmt
    
    serr1 = SqlFetch1(c1, strSQLStmt, bContResult, LenB(bContResult))
    
    'SqlFetch returns 0 if records are returned or NOTFOUND if no records are returned
    If serr1 = NOTFOUND Then
        'Call MessBox("Error Locating Project " + SParm(strProjectID), MB_OK, "Can't Assign TermsID")
        Exit Sub
    Else
        'Check to see if the terms field is enabled or not so we don't modify posted records
        If cTerms.Enabled = True Then
            strTermsID = bContResult.termsid
            'Call MessBox("Assign TermsID: " + strTermsID, MB_OK, "Terms to assign")
            'Call SetObjectValue("cTerms", strTermsID)
            
            Call SetBufferValue("bpjinvhdr.ih_id18", strTermsID)
            
        End If
    End If
    
End Sub


On the field "cTerms" itself I've removed the values under default since we want to use the above logic and that is the only change I made to it. Any help or a pointer to the right direction would be greatly appreciated!


Viewing all articles
Browse latest Browse all 2378

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>