Skip to main content
November 2, 2022
Solved

Interface to retrieve record

  • November 2, 2022
  • 7 replies
  • 0 views

Hi, I am tasked to do a timesheet POC,

I am asking the user to select the date, and I will using the weeknum function to find out the week number,

after that will add into the database and wait for supervisor approval. 

How to verify the week number is exist in the database record before the user submits the form. 

Please kindly assist me thank you 

    Best answer by amans0009

    try this, if this returns true then value exists otherwise it doesn't exist in the data base 

    contains(a!queryEntity(
      entity: cons!TS_TIMESHEET_DS_POINTER,
      query: a!query(
        logicalExpression: a!queryLogicalExpression(
          operator: "AND",
          filters: {
            a!queryFilter(
              field: "workweek",
              operator: "=",
              value: ri!weekNum
            )
          },
          ignoreFiltersWithEmptyValues: true
        ),
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 50
        )
      ),
      fetchTotalCount: true
    ).data."workweek",ri!weekNum)

    7 replies

    amans0009
    November 2, 2022

    add validation to the week number field by querying the data from data base and check if the entered week number exist in that , based on conditions you can add validations or please elaborate more.  

    November 2, 2022

    you mean do the validation on the week Number field, I have write an expression rule to retrieve the record from database filter via when the weekNum = ri!weekNum.

    but I don't know how to call the rule at interface and checking the weeknum based on the user input. 

    amans0009
    November 2, 2022

    here is the code for adding validation

    {
      a!dateField(
        label: "Date",
        labelPosition: "ABOVE",
        value: ri!date,
        saveInto: {ri!date},
        validations: {if(ri!date>today(),{},"enter a valid date")}
        //if ou have a rule for deciding then
        // validations : if(rule!yourRule(ri!date),{},"not a valid week"
      )
    }

    it will restrict the user from submiting the form untill that field is valid , plus you have to validate the submit button.