EducationSoftwareStrategy.com
StrategyCommunity

Knowledge Base

Product

Community

Knowledge Base

TopicsBrowse ArticlesDeveloper Zone

Product

Download SoftwareProduct DocumentationSecurity Hub

Education

Tutorial VideosSolution GalleryEducation courses

Community

GuidelinesGrandmastersEvents
x_social-icon_white.svglinkedin_social-icon_white.svg
Strategy logoCommunity

© Strategy Inc. All Rights Reserved.

LegalTerms of UsePrivacy Policy
  1. Home
  2. Topics

KB32862: How to update/change an attribute element prompt default answers using Microstrategy Web SDK


Community Admin

• Strategy


How to update/change an attribute element prompt default answers using Microstrategy Web SDK

The following code can be used to change/update the default answer of all attribute element prompts based on the same attribute. 
 
WebObjectSource wos = webObjectFactory.getObjectSource();
WebSearch search = wos.getNewSearchObject();
WebPrompt prompt = null;
WebElementsPrompt elemprompt = null;
WebElementsPrompt promptinfo = null;           
//------------------------
//this example looks for all Month attribute element prompts with default answer and change it to a new value
//search can be narrowed to a specific prompt names
//asynchronized search
  search.setAsync(false);
//search for prompt
search.types().add(new Integer(EnumDSSXMLObjectTypes.DssXmlTypePrompt));
search.submit();
WebFolder f = search.getResults();
 if(!f.isEmpty())
  {
     for(int i=0;i<f.size();i++)
  {
     prompt = (WebPrompt) f.get(i);
     prompt.populate();
   //only work with prompts with default answers
     if(prompt.hasDefaultAnswer())
    {
      //only work with attribute element prompts
     if(prompt.getPromptType()== EnumWebPromptType.WebPromptTypeElements)
         {
          elemprompt = (WebElementsPrompt) prompt;
          if(elemprompt.getOrigin().getName().equals("Month"))
            {
              //change value for one prompt 
                                                                
wos.setFlags(wos.getFlags() | EnumDSSXMLObjectFlags.DssXmlObjectBrowser );
promptinfo = (WebElementsPrompt)wos.getObject(elemprompt.getID(), EnumDSSXMLObjectTypes.DssXmlTypePrompt,true);
                                                                               
WebElements elements = promptinfo.getDefaultAnswer();
elements.clear();
//new answer Month Attribute ID:Element 
elements.add("8D679D4411D3E4981000E787EC6DE8A4:200705"); 
promptinfo.setAnswer(elements); 
wos.save(promptinfo);                                         
                                                        }
                                                }
                                        }
                                }
                        }
 
 
 
 
 
 
CUSTOMIZATION WARNING:
This customization is provided as a convenience to Strategy users and is only directly applicable to the version stated. While this code may apply to other releases directly, Strategy Technical Support makes no guarantees that the code provided will apply to any future or previous builds. In the event of a code change in future builds, Strategy Technical Support makes no guarantee that an updated version of this particular customization will be provided. In the event of a code change in future builds, Strategy may not be able to provide additional code on this matter even though this customization is provided at this time for this specific build. For enhancements to this customization or to incorporate similar functionality into other versions, contact your Account Executive to inquire about Strategy Consulting assistance.


Comment

0 comments

Details

Knowledge Article

Published:

June 12, 2017

Last Updated:

June 12, 2017