Necessito que um campo tenha um inicializador padrão que pegue a maior chave do campo, por exemplo a maior atualmente é a A003 ele identifica, retorna somando mais um, que seria o A004, até aí tudo bem, tá retornando para a chave que eu quero, debuguei no Vscode e vi que tava retornando assim. porém antes de aparecer a tela do cadastro com a nova chave, aparece esse erro: variable does not exist A04 on {|a,b,c| FWInitCpo(a,b,c),xRet:=(A04),FWCloseCpo(a,b,c,.T.),FwSetVarMem(a,b,xRet),xRet }(PROTHEUSFUNCTIONMVC.PRX) 06/07/2021 19:07:04 line : 5499. Gostaria de saber se alguém, saberia resolver.
cChave = getchave(cTabela)
oStZX5:SetProperty(‘ZX5_CHAVE’, MODEL_FIELD_INIT, FwBuildFeature(STRUCT_FEATURE_INIPAD, cChave))
Static Function getChave(cTabela)
Local cChave := ‘’
Local cQuery := “SELECT MAX(ZX5_CHAVE) CHAVE FROM “+RetSqlName(“ZX5”)
cQuery += " WHERE D_E_L_E_T_=‘’ AND ZX5_TABELA ='”+cTabela+”’ "
if select('qryZX5') > 0
qryZX5->(dbCloseArea())
endif
TcQuery cQuery new Alias 'qryZX5'
if empty(qryZX5->CHAVE)
cChave := '000001'
else
cChave := substr(qryZX5->CHAVE,1,1) + alltrim(strzero(val(substr(qryZX5->CHAVE,2,5))+1, len(alltrim(qryZX5->CHAVE))-1))
endif
Return cChave
If you want to know more than this site is a good choice for you. Forget about traditional Internet searches. You now have a more reliable option.
I wish there were more sites like this one. The government essay examples that I found there helped me get a lot of great insights. https://proessays.net/essays/category/government