Closed ViniciusLevyC closed 1 year ago
@ViniciusLevyC,
First, you need to get Attribute. You can get it by ID, or name.
attr = Attribute(conn, id="abcdef...")
Then, using your attribute object (e.g. attr), you can
attr.forms
to list all attribute formsattr.get_form()
to get form by id or name. Check this page for examples.
Hi @xdumstr thanks for you message.
I tried implement that, but my code does not work.
I am trying print informations about Dossier, like:
Dossier Name Dossier ID --- Datasets/Cubes Names --- Datasets/Cubes ID ------- Attributes Name ------- Attributes ID ----------- Attribute Forms Name ----------- Attribute Expression ----------- Expression Tables Used ------- Metrics Name ------- Metrics ID ----------- Metrics Table Column Used ----------- Metrics Table Name
I have part of these informations, but I start to have problems when I try shows Form Names.
I attached my code here, just for understand which I stop and which steps I tried.
So, thanks for your help! If I have some evolution I post here.
Hi @ViniciusLevyC can you describe in more detail what problem do you have with form name?
Hello @mstrpr
Sure... If you look the image I attached on my first post, we can see the yellow column "Form Name" and other column "Form Category", I attached my script on my last post (just to show my steps and maybe help me to adjust). Every time I tried print the Form Name, my console shows the form category, how I know that? Because the result is "Cliente ID", "Cliente None", "Cliente None 2", "Cliente None 3", etc.
To be honestly, I don't have any other idea how can I get Form Name, I read loads of time the documentation, tried change my script, but without any success.
If you have any other idea, let me know please!
Thanks a lot!
So form is an object in mstrio, so you can just access its name by dot notation form.name
.
Here how to print names of all forms of an attribute:
attr_forms = Attribute(conn, id='attribute id').forms
for form in attr_forms:
print(form.name)
Let me know if this helps.
@mstrpr I tried and received an error.
Console result:
Nome do Dossier: Relatório Operacional Interno
**********************************************************
Nome dataset: Cubo NRT - V_VEL_INTERNOS_NRT Report Operacional Interno
ID: 6EB1A4C94F668F5D33E555925BD04888
**********************************************************
Nome do atributo: Cliente
Descrição do atributo: Nome do Cliente
ID do Atributo: 6FB5F7904155CC2DC157B288D4B0AC8D
Error getting attribute with ID: 6FB5F7904155CC2DC157B288D4B0AC8D
I-Server Error 8004cb07, Error when restoring the idToken: Required property 'identityTokenSecretKey' for identity token generation is not configured
Ticket ID: None
Unexpected error during PyExec Python code execution: Traceback (most recent call last):
File "C:\tools\msys\20160205-3\var\lib\jenkins\workspace\PyExec-.-m2021_24-.-stage-1-dev-win\production\pyexec.py", line 24, in <module>
File "<PyExec: inline code>", line 74, in <module>
File "mstrio\utils\version_helper.py", line 42, in inner
File "mstrio\modeling\schema\attribute\attribute.py", line 453, in __init__
File "mstrio\utils\entity.py", line 150, in __init__
File "mstrio\utils\entity.py", line 203, in fetch
File "mstrio\utils\api_helpers.py", line 39, in unpack_information_inner
File "mstrio\utils\error_handlers.py", line 59, in inner
File "mstrio\utils\helper.py", line 243, in response_handler
mstrio.utils.helper.IServerError: Error when restoring the idToken: Required property 'identityTokenSecretKey' for identity token generation is not configured; code: '8004cb07', ticket_id: 'None'
I don't understand why the script is not working.
Let me show what I did:
# Imput Dossier ID
dossier_id = 'my Dossier ID'
# Get Dossier (ID)
dossiers = list_dossiers(connection=conn, project_id=project_id, id=dossier_id)
dossier = dossiers[0]
# Print Dossier Name
print("**********************************************************\n")
print(f"Nome do Dossier: {dossier.name}")
print("\n")
# Get Dossier Dependencies
dependencies = dossier.list_dependencies(type=3)
# Print Dataset ID and Name
for i in range(len(dependencies)):
dataset = dependencies[i].get('name')
dataset_id = dependencies[i].get('id')
print("**********************************************************\n")
print(f"Nome dataset: {dataset}")
print(f"ID: {dataset_id}")
print("**********************************************************\n")
# Get Dataset Reports
dataset2 = list_reports(connection=conn, project_id=project_id, id=dataset_id)
for x in range(len(dataset2)):
report = dataset2[x]
# Get Dataset Dependencies
dependencies2 = report.list_dependencies()
# Print Dependencies
for dependency in dependencies2:
# IF Type related on Attribute, Print Name, Description and ID
if dependency.get('type') in [12, 21] and dependency.get('subtype') in [3072, 5377]:
print(f"\n\tNome do atributo: {dependency.get('name')}")
print(f"\n\tDescrição do atributo: {dependency.get('description')}")
print(f"\n\tID do Atributo: {dependency.get('id')}")
attr_id = dependency.get('id')
attr_forms = Attribute(connection=conn, id=attr_id).forms
for form in attr_forms:
print(form.name)
@ViniciusLevyC
This error: IServerError: Error when restoring the idToken: Required property 'identityTokenSecretKey' for identity token generation is not configured;
is a problem with the server.
Here's article describing it: link
See if it helps.
Hello @mstrpr Thanks for your help, I followed the article steps, and I saw the form name result, now I have another error, but I will check if I have any sintax or other thing to change. Thank you so much!
Hi people! Is there any way to get the form names passing the attribute id? I attached the example for what I need. Thanks a lot!