SaveById API call response is not as expected

Posted by: laura-andreea.holban on 24 January 2024, 3:37 am EST

    • Post Options:
    • Link

    Posted 24 January 2024, 3:37 am EST - Updated 24 January 2024, 11:43 pm EST

    Hi! In the code snippet below, I’m using SaveById method to make an api call to “ar/reports/{id}/content?type=rpx” in order to save a report to AppData folder.

    const designer = (window as any).GrapeCity.ActiveReports.Designer.apiOf(InstanceID);
    designer.documents.saveById(documentId, props.mode).then((res: any) => {
          console.log(res);
        });

    This uses a custom UpdateReport method which saves the report and returns the filename:

    public string UpdateReport(string id, GrapeCity.ActiveReports.SectionReport report)
    {
    	var reportHelper = new ReportHelper(_context, _jsonSerializerOptions);
    
    	switch (id)
    	{
    		case "ExternallyViewable.rpx":
    			reportHelper.UpdateHeader(Web.Models.Data.Enum.ReportHeaderEditMode.ExternallyViewable, report);
    			break;
    		case "RemittanceAdvice.rpx":
    			reportHelper.UpdateHeader(Web.Models.Data.Enum.ReportHeaderEditMode.RemittanceAdvice, report);
    			break;
    		case "Export.rpx":
    			return SaveReport(id, report, true);
    		default: throw new ArgumentOutOfRangeException("Unknown section report ID (" + id + ")");
    	}
    
    	return "dummy text";
    }

    I can see in the browser dev tools that the response is the filename of the newly created file returned by the UpdateReport method as I would expect (it can be seen in the attached Screenshot1):



    However, I noticed that the response actually received in the “then” hook is different (as shown in Screenshot2).



    I need to retrieve that filename in order to use it in a different API call to trigger a download. This functionality was working before, so has the method SaveById or the Active Reports APIs changed recently? How would I be able to retrieve that filename from the response?

  • Posted 28 January 2024, 7:40 pm EST

    Hi Andreea,

    For retrieving filename you may refer to the following lines of code:

      designer.documents.saveById('MyReport.rdlx').then((result) => {
                console.log(result);
                window.document.getElementById("reportName").innerHTML = result.name;
            });
    

    In the above code, result.name can be used to get the file name. For more information on the result, please refer to the following page of our documentation: SaveDocumentInfo

    Please refer to the attached sample report

    >> This functionality was working before, so has the method SaveById or the Active Reports APIs changed recently?

    As I can see even the ActiveReports 16 documentation(Previous version) shows the same method return type for saveByID method and it seems that this behavior hasn’t officially changed since ActiveReports 15.

    WebDesigner_CustomStore.zip

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels