Loading
CRM Analytics
Índice
Selecionar filtros

          Sem resultados
          Sem resultados
          Aqui estão algumas dicas de pesquisa

          Verifique a grafia das palavras-chave.
          Tente utilizar termos mais genéricos.
          Selecione menos filtros para ampliar sua pesquisa.

          Pesquisar em toda a Ajuda do Salesforce
          Criar uma página do Visualforce que executa a ação

          Criar uma página do Visualforce que executa a ação

          A página do Visualforce chama os métodos definidos na classe do controlador do Apex para invocar a ação e fornecer um status das tarefas.

          1. Em configuração, insira Visualforce na caixa Busca rápida.
          2. Selecione Páginas do Visualforce.
          3. Clique em Novo.
          4. Insira o rótulo e a descrição da página do Visualforce.
            Defina os detalhes sobre a página do Visualforce.
          5. Substitua a marcação existente por esse código.
            <apex:page controller="CreateOpportunitiesController" action="{!init}" showheader="false" sidebar="false" standardStylesheets="false" title="Create Opportunities" >
                <apex:stylesheet value="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css"/>
            
            /* Use jQuery to process API calls */
                <apex:includeScript value="https://code.jquery.com/jquery-3.1.0.min.js"/>
                <style>
                    th {
                        width: 50%;
                    }
                    h4 {
                        font-size: 24px;
                    }
                    table {
                        font-size: 20px;
                        width: 100%;
                    }
                </style>
                <div class="container-fluid">
            
            /* Add HTML table to the Visualforce page that shows the accounts, the opportunity creation status, and then finally the new opportunity name */
                    <h4 id="message">Querying Accounts...</h4>
                    <table name="results" id="results" data-role="table" class="table-bordered table-striped table-responsive">
                        <thead><tr><th>Account</th><th>Opportunity</th></tr></thead>
                        <tbody></tbody>
                    </table>
                </div>
                
                <script>
                    $(function() {
                        $.ajaxSetup({
                            headers: {"Authorization": 'Bearer {!$Api.Session_ID}'}
                        });
                        
                        setTimeout(executeQuery, 1000);
                    });
            
            /* Executes the SAQL query and displays the resulting accounts. Note: Account.Name and AccountId referenced below refer to the dataset field names. Update them to match your dataset fields. */                
                    function executeQuery() {
                        // Replace this with the actual SAQL query needed to fetch data for this page
                        var query = {};
                        query.statements = "{!JSENCODE(query)}";
                        var queryObj = {query: query.statements};
                        $.ajax({
                            type: 'POST',
                            url: '/services/data/v39.0/wave/query',
                            data: JSON.stringify(queryObj),
                            contentType: 'application/json',
                            success: function(data) {
                                $('#message').html('Creating Opportunities...');
                                var record = null;
                                var row = null;
                                $('#results tbody').empty();
                                
                                for (var i = 0; i < data.results.records.length; i++) {
                                    record = data.results.records[i];
                                    row = $('<tr>');
                                    row.append($('<td>').html(record['Account.Name']));
                                    row.append($('<td class="' + record.AccountId + '">').html('Creating...'));
                                    $('#results tbody').append(row);
                                }
                                
                                setTimeout(function() {createOpportunities(data.results.records);}, 1000);
                            },
                        });
                    }
            
            /* Calls the Apex controller method that creates opportunities for each account and returns the opportunity name for each account to the HTML table. */
                    function createOpportunities(accountRecords) {
                        CreateOpportunitiesController.create(accountRecords, function(result, event) {
                            console.log(result);
                            if (event.status) {
                                for (var i = 0; i < accountRecords.length; i++) {
                                    $('td.' + accountRecords[i].AccountId).html(result[accountRecords[i].AccountId]);
                                }
                                $('#message').html(accountRecords.length + ' Opportunities Created');
                            }
                            else {
                                $('#message').html('Error: ' + event.message);
                            }
                        });
                    }
                </script>
            </apex:page>
          6. Clique em Salvar.
           
          Carregando
          Salesforce Help | Article