Using RecordRef and FieldNo Instead of dependency to get fields from another extension

samantha73
samantha73 Member Posts: 125

Hi All

We can get fields from another extension by using something like below without delcaring dependency in app.json file. Are there pros and cons with just using recordref vs dependecy. Eitherway if the field is not there second ext wil fail

local procedure TryGetFieldValue(RecRef: RecordRef; FieldNo: Integer; var FieldValue: Text)    var       

FldRef: FieldRef;   

begin       

FldRef := RecRef.Field(FieldNo);       

FieldValue := Format(FldRef.Value);   

end;

No need of below

  "dependencies": [    {    "id": "a5727ce6-368c-49e2-84cb-1a6052f0551d",    "publisher": "ABC",    "name": "ABC PTE",    "version": "5.61.260.271"  }],

Best Answer

Answers

  • RockWithNAV
    RockWithNAV Member Posts: 1,200
    Answer ✓

    I will prioritize the RecRef option instead of adding the dependency. Dependency will always make your extension file dependent on this and extension and moreover you won't be able to take your solution to AppSource if you are building a product. So go with RecRef.

  • kriki
    kriki Member, Moderator Posts: 9,133

    I also have done that. And to avoid failing in case the extension does not exist, I always check the "Field" table to see if that field exists.

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!