cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

use case for "Application.getfiledatasource" ?

oliver_raths
Participant
0 Kudos
1,910

hi

what is the use case for "Application.getfiledatasource" ?

when to use the filedatasource?

what exactly is the different between the datasourc and the filedatssource object?

br Oliver

Accepted Solutions (1)

Accepted Solutions (1)

DenisT
Explorer
0 Kudos

Hi @oliver_raths,

I know your question ist quite old and you surely have found a solution. But since I just stumbled upon this discussion and for everyone else who may find this discussion, I´d like to add the following:

You must use the ID of the model, not the technical name or description. The ID will look like "Cu4o1l0eqjiphse1tosogajc2u".

You can look up the ID in the model "RESOURCE", which is available on every SAC. Please filter the "Object Name" to the technical name of your model (like your "testquery") and output the "Object ID". This is the ID you want to use in Application.getfiledatasource.

So the coding in your example will look like:

ds = getFiledatasource("Cu4o1l0eqjiphse1tosogajc2u");
ds.setVariableValue("0I_FPER",{from:time_range_from_array[1],to:time_range_to_array[1]});

Best regards,
Denis

sv7en
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi @DenisT ,

Thanks for your solution!
However, I still don't understand where the modelId is obtained from. My understanding is that it should be the technical name of a model taken from the Data Source to serve as the modelId. But in the logs, the information indicates an incorrect parameter setting, so I'm unclear about what's happening. Do you have more specific details? Looking forward to your response!

sv7en_1-1749697661100.png

sv7en_1-1749710903179.png

 

sv7en_0-1749710887593.png

 

Best Regards,
Wenjun

 

DenisT
Explorer

Hi @sv7en,
please note that you have:

  • a Model Name (=technical name), like SAP_GRL_RL_EmissionComparisonKPI or TITECON_Demo_Model
  • a Model Description, like "Emmision Comparison KPI" or "Demo Model"
  • a Model ID, like "Cu4o1l0eqjiphse1tosogajc2u"

The first ones are the ones you usually see if you e.g. use the files browser in SAC. The model ID you can e.g. get by:

  • Using the Data Analyzer on the SAC Standard Model "RESOURCE": There you filter on the Model Name and output the Model ID. This method is especially helpful, if you´d like to get the IDs of several Models
  • Using coding. If you´re already coding anyways, you can just use this method.

Let´s dive into the coding option and let´s assume you have a Table named "P1_TAB_Demo", connected to a model (in my case with the name "TITECON_Demo_Model"). Now create a button with an onClick Script event:

console.log (P1_TAB_Demo.getDataSource().getInfo());

This will result can be shown in the browser developer tools console (F12):

DenisT_1-1749803252574.png

So in my Example the model ID output is "t.8:Ca0dju0b3o8jdb3sh78rh61a35r", where "t.8" is the Content Namespace of the SAC tenant, which is not relevant, so the model ID you should use in your further coding is only "Ca0dju0b3o8jdb3sh78rh61a35r". 

Just hit me directly, if you need any further assistance.

Best regards,
Denis

 

 

Answers (1)

Answers (1)

N1kh1l
Active Contributor
0 Kudos

oliver_raths

getFileDataSource(modelId: string): FileDataSource

Returns the data source of related modelId. No widget tagging required

lets say you have multiple widgets like Table1 , Chart 1 etc. ( same data source) and want to perform some logic for all of them

getDataSource(): DataSource

You would need a widget to tag this datasource.

Nikhil

oliver_raths
Participant
0 Kudos

hi Nikhil,

i tried the following =>

4 charts bases on the same datasource/query ("testquery")

chart1; chart2; chart3; chart4

************************************************

ds = getFiledatasource("testquery");

ds.setVariableValue("0I_FPER",{from:time_range_from_array[1],to:time_range_to_array[1]});

=> no reaction in the 4 charts for the new variable setting

****************************************

ds = chart1.getdatasource

ds.setVariableValue("0I_FPER",{from:time_range_from_array[1],to:time_range_to_array[1]});

=> all 4 charts refreshes the data for the new variable setting

****************************************

N1kh1l
Active Contributor
0 Kudos

oliver_raths

Could you please console.log the 2 ds variables and see what are they returning. I remember the use case being what i described in my resposne but I will check it again.