Good morning people Still on this code, I'm facing...
# suitescript
s
Good morning people Still on this code, I'm facing another problem. It doesn't return any errors, however, it doesn't make changes like changes when I make changes to the invoice.
Copy code
//Carrega registro Term
        /*var objTerm = record.load({
            type: record.Type.TERM,
            id: 193,
            isDynamic: true
        });
		*/

      //Carrega registro Fatura
        var objFatura = record.load({
            type: record.Type.INVOICE,
            id: 4952604,
            isDynamic: true
        });

        //Obtém valor da campo duenextmonthifwithindays que está dentro da fatura Term
      	  /*var nTerm = objFatura.getValue({
           		fieldId: "duenextmonthifwithindays"
        	});
           */

		var anyData = "20/11/2021";

          var AcceptNTerm = format.format({
            value: anyData,
            type: format.Type.DATE
          });

        //Define valor de duedate com o valor obtido do objeto objTerm
        objFatura.setValue({
            fieldId: "custrecord_gf_data_prevista",
            value: AcceptNTerm,
            ignoreFieldChange: false
          });

         var recordId = objFatura.save({
        	enableSourcing: true,
            ignoreMandatoryFields: false
      });

      return recordId;
    }
d
nothing in system info of the invoice>
?
s
Can you change the field in the UI? Try using
setText
instead of
setValue
. As I said yesterday,
setText
is for strings,
setValue
is for dates.
format.format
returns a string, you could try using
format.parse
instead as well, I personally would just avoid using
N/format
completely.
s
@Damree Ilyaad Returns no error. I think I'm on the right path and I'll be there soon to be able to solve this problem. hope so
@Sandii Okay, I'll try. Thanks. I have been trying other alternatives that I found elsewhere.
Hey @Sandii Where do I make these setText changes? Only one detail, the value I want to get to be able to change the deadline, is the Number type. This field in order to change the deadline. Another user commented that I should use Date with setValue, setting a specific date. However, what I need is to get the value of this field and include it in the deadline.
s
use setText instead of setValue
your script doesnt seem to indicate anything about manipulating a date
s
I'm trying to change this field.
And I'm including any date, just to see if anything changes
s
Right, you can change it to somethign by using
setText
with a date string, if you want to use
setValue
to change it, then you need to give a Date, not a string
👍 1
Copy code
var anyData = "20/11/2021";

          var AcceptNTerm = format.format({
            value: anyData,
            type: format.Type.DATE
          });
anyData
and
AcceptNTerm
are both strings, they will not work with
setValue
👍 1
s
@Sandii I understood! Thank you very much 😄
d
@Slig Its working?
s
Hey, @Damree Ilyaad Haven't tested it yet. I'm doing other tasks for the company. I'll let you know if it works. Thanks 😄